@@ -2,6 +2,7 @@ package v1alpha2
22
33import (
44 corev1 "k8s.io/api/core/v1"
5+ apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
56 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
67
78 "github.com/nginx/nginx-gateway-fabric/apis/v1alpha1"
@@ -388,6 +389,36 @@ type KubernetesSpec struct {
388389 Service * ServiceSpec `json:"service,omitempty"`
389390}
390391
392+ // Patch defines a patch to apply to a Kubernetes object.
393+ type Patch struct {
394+ // Type is the type of patch. Defaults to StrategicMerge.
395+ //
396+ // +optional
397+ // +kubebuilder:default:=StrategicMerge
398+ Type * PatchType `json:"type,omitempty"`
399+
400+ // Value is the patch data as raw JSON.
401+ // For StrategicMerge and Merge patches, this should be a JSON object.
402+ // For JSONPatch patches, this should be a JSON array of patch operations.
403+ //
404+ // +optional
405+ // +kubebuilder:validation:XPreserveUnknownFields
406+ Value * apiextv1.JSON `json:"value,omitempty"`
407+ }
408+
409+ // PatchType specifies the type of patch.
410+ // +kubebuilder:validation:Enum=StrategicMerge;Merge;JSONPatch
411+ type PatchType string
412+
413+ const (
414+ // PatchTypeStrategicMerge uses strategic merge patch.
415+ PatchTypeStrategicMerge PatchType = "StrategicMerge"
416+ // PatchTypeMerge uses merge patch (RFC 7386).
417+ PatchTypeMerge PatchType = "Merge"
418+ // PatchTypeJSONPatch uses JSON patch (RFC 6902).
419+ PatchTypeJSONPatch PatchType = "JSONPatch"
420+ )
421+
391422// Deployment is the configuration for the NGINX Deployment.
392423type DeploymentSpec struct {
393424 // Container defines container fields for the NGINX container.
@@ -404,6 +435,11 @@ type DeploymentSpec struct {
404435 //
405436 // +optional
406437 Pod PodSpec `json:"pod"`
438+
439+ // Patches are custom patches to apply to the NGINX Deployment.
440+ //
441+ // +optional
442+ Patches []Patch `json:"patches,omitempty"`
407443}
408444
409445// DaemonSet is the configuration for the NGINX DaemonSet.
@@ -417,6 +453,11 @@ type DaemonSetSpec struct {
417453 //
418454 // +optional
419455 Pod PodSpec `json:"pod"`
456+
457+ // Patches are custom patches to apply to the NGINX DaemonSet.
458+ //
459+ // +optional
460+ Patches []Patch `json:"patches,omitempty"`
420461}
421462
422463// PodSpec defines Pod-specific fields.
@@ -594,6 +635,11 @@ type ServiceSpec struct {
594635 //
595636 // +optional
596637 NodePorts []NodePort `json:"nodePorts,omitempty"`
638+
639+ // Patches are custom patches to apply to the NGINX Service.
640+ //
641+ // +optional
642+ Patches []Patch `json:"patches,omitempty"`
597643}
598644
599645// ServiceType describes ingress method for the Service.
0 commit comments