Skip to content

Commit 0d0cd31

Browse files
committed
Add ability to patch dataplane Service, Deployment, and DaemonSet in NginxProxy
1 parent 0ca388f commit 0d0cd31

File tree

7 files changed

+608
-25
lines changed

7 files changed

+608
-25
lines changed

apis/v1alpha2/nginxproxy_types.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package v1alpha2
22

33
import (
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,35 @@ 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+
// +kubebuilder:validation:XPreserveUnknownFields
405+
Value *apiextv1.JSON `json:"value"`
406+
}
407+
408+
// PatchType specifies the type of patch.
409+
// +kubebuilder:validation:Enum=StrategicMerge;Merge;JSONPatch
410+
type PatchType string
411+
412+
const (
413+
// PatchTypeStrategicMerge uses strategic merge patch.
414+
PatchTypeStrategicMerge PatchType = "StrategicMerge"
415+
// PatchTypeMerge uses merge patch (RFC 7386).
416+
PatchTypeMerge PatchType = "Merge"
417+
// PatchTypeJSONPatch uses JSON patch (RFC 6902).
418+
PatchTypeJSONPatch PatchType = "JSONPatch"
419+
)
420+
391421
// Deployment is the configuration for the NGINX Deployment.
392422
type DeploymentSpec struct {
393423
// Container defines container fields for the NGINX container.
@@ -404,6 +434,11 @@ type DeploymentSpec struct {
404434
//
405435
// +optional
406436
Pod PodSpec `json:"pod"`
437+
438+
// Patches are custom patches to apply to the NGINX Deployment.
439+
//
440+
// +optional
441+
Patches []Patch `json:"patches,omitempty"`
407442
}
408443

409444
// DaemonSet is the configuration for the NGINX DaemonSet.
@@ -417,6 +452,11 @@ type DaemonSetSpec struct {
417452
//
418453
// +optional
419454
Pod PodSpec `json:"pod"`
455+
456+
// Patches are custom patches to apply to the NGINX DaemonSet.
457+
//
458+
// +optional
459+
Patches []Patch `json:"patches,omitempty"`
420460
}
421461

422462
// PodSpec defines Pod-specific fields.
@@ -594,6 +634,11 @@ type ServiceSpec struct {
594634
//
595635
// +optional
596636
NodePorts []NodePort `json:"nodePorts,omitempty"`
637+
638+
// Patches are custom patches to apply to the NGINX Service.
639+
//
640+
// +optional
641+
Patches []Patch `json:"patches,omitempty"`
597642
}
598643

599644
// ServiceType describes ingress method for the Service.

apis/v1alpha2/zz_generated.deepcopy.go

Lines changed: 55 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/gateway.nginx.org_nginxproxies.yaml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,32 @@ spec:
511511
type: object
512512
type: array
513513
type: object
514+
patches:
515+
description: Patches are custom patches to apply to the NGINX
516+
DaemonSet.
517+
items:
518+
description: Patch defines a patch to apply to a Kubernetes
519+
object.
520+
properties:
521+
type:
522+
default: StrategicMerge
523+
description: Type is the type of patch. Defaults to
524+
StrategicMerge.
525+
enum:
526+
- StrategicMerge
527+
- Merge
528+
- JSONPatch
529+
type: string
530+
value:
531+
description: |-
532+
Value is the patch data as raw JSON.
533+
For StrategicMerge and Merge patches, this should be a JSON object.
534+
For JSONPatch patches, this should be a JSON array of patch operations.
535+
x-kubernetes-preserve-unknown-fields: true
536+
required:
537+
- value
538+
type: object
539+
type: array
514540
pod:
515541
description: Pod defines Pod-specific fields.
516542
properties:
@@ -3944,6 +3970,32 @@ spec:
39443970
type: object
39453971
type: array
39463972
type: object
3973+
patches:
3974+
description: Patches are custom patches to apply to the NGINX
3975+
Deployment.
3976+
items:
3977+
description: Patch defines a patch to apply to a Kubernetes
3978+
object.
3979+
properties:
3980+
type:
3981+
default: StrategicMerge
3982+
description: Type is the type of patch. Defaults to
3983+
StrategicMerge.
3984+
enum:
3985+
- StrategicMerge
3986+
- Merge
3987+
- JSONPatch
3988+
type: string
3989+
value:
3990+
description: |-
3991+
Value is the patch data as raw JSON.
3992+
For StrategicMerge and Merge patches, this should be a JSON object.
3993+
For JSONPatch patches, this should be a JSON array of patch operations.
3994+
x-kubernetes-preserve-unknown-fields: true
3995+
required:
3996+
- value
3997+
type: object
3998+
type: array
39473999
pod:
39484000
description: Pod defines Pod-specific fields.
39494001
properties:
@@ -6996,6 +7048,32 @@ spec:
69967048
- port
69977049
type: object
69987050
type: array
7051+
patches:
7052+
description: Patches are custom patches to apply to the NGINX
7053+
Service.
7054+
items:
7055+
description: Patch defines a patch to apply to a Kubernetes
7056+
object.
7057+
properties:
7058+
type:
7059+
default: StrategicMerge
7060+
description: Type is the type of patch. Defaults to
7061+
StrategicMerge.
7062+
enum:
7063+
- StrategicMerge
7064+
- Merge
7065+
- JSONPatch
7066+
type: string
7067+
value:
7068+
description: |-
7069+
Value is the patch data as raw JSON.
7070+
For StrategicMerge and Merge patches, this should be a JSON object.
7071+
For JSONPatch patches, this should be a JSON array of patch operations.
7072+
x-kubernetes-preserve-unknown-fields: true
7073+
required:
7074+
- value
7075+
type: object
7076+
type: array
69997077
type:
70007078
default: LoadBalancer
70017079
description: ServiceType describes ingress method for the

0 commit comments

Comments
 (0)