Skip to content

Commit da6ed02

Browse files
committed
Add ability to patch dataplane Service, Deployment, and DaemonSet in NginxProxy
1 parent b5cf4be commit da6ed02

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
// Number of desired Pods.
@@ -404,6 +434,11 @@ type DeploymentSpec struct {
404434
//
405435
// +optional
406436
Container ContainerSpec `json:"container"`
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
Container ContainerSpec `json:"container"`
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.
@@ -569,6 +609,11 @@ type ServiceSpec struct {
569609
//
570610
// +optional
571611
NodePorts []NodePort `json:"nodePorts,omitempty"`
612+
613+
// Patches are custom patches to apply to the NGINX Service.
614+
//
615+
// +optional
616+
Patches []Patch `json:"patches,omitempty"`
572617
}
573618

574619
// 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
@@ -489,6 +489,32 @@ spec:
489489
type: object
490490
type: array
491491
type: object
492+
patches:
493+
description: Patches are custom patches to apply to the NGINX
494+
DaemonSet.
495+
items:
496+
description: Patch defines a patch to apply to a Kubernetes
497+
object.
498+
properties:
499+
type:
500+
default: StrategicMerge
501+
description: Type is the type of patch. Defaults to
502+
StrategicMerge.
503+
enum:
504+
- StrategicMerge
505+
- Merge
506+
- JSONPatch
507+
type: string
508+
value:
509+
description: |-
510+
Value is the patch data as raw JSON.
511+
For StrategicMerge and Merge patches, this should be a JSON object.
512+
For JSONPatch patches, this should be a JSON array of patch operations.
513+
x-kubernetes-preserve-unknown-fields: true
514+
required:
515+
- value
516+
type: object
517+
type: array
492518
pod:
493519
description: Pod defines Pod-specific fields.
494520
properties:
@@ -3900,6 +3926,32 @@ spec:
39003926
type: object
39013927
type: array
39023928
type: object
3929+
patches:
3930+
description: Patches are custom patches to apply to the NGINX
3931+
Deployment.
3932+
items:
3933+
description: Patch defines a patch to apply to a Kubernetes
3934+
object.
3935+
properties:
3936+
type:
3937+
default: StrategicMerge
3938+
description: Type is the type of patch. Defaults to
3939+
StrategicMerge.
3940+
enum:
3941+
- StrategicMerge
3942+
- Merge
3943+
- JSONPatch
3944+
type: string
3945+
value:
3946+
description: |-
3947+
Value is the patch data as raw JSON.
3948+
For StrategicMerge and Merge patches, this should be a JSON object.
3949+
For JSONPatch patches, this should be a JSON array of patch operations.
3950+
x-kubernetes-preserve-unknown-fields: true
3951+
required:
3952+
- value
3953+
type: object
3954+
type: array
39033955
pod:
39043956
description: Pod defines Pod-specific fields.
39053957
properties:
@@ -6952,6 +7004,32 @@ spec:
69527004
- port
69537005
type: object
69547006
type: array
7007+
patches:
7008+
description: Patches are custom patches to apply to the NGINX
7009+
Service.
7010+
items:
7011+
description: Patch defines a patch to apply to a Kubernetes
7012+
object.
7013+
properties:
7014+
type:
7015+
default: StrategicMerge
7016+
description: Type is the type of patch. Defaults to
7017+
StrategicMerge.
7018+
enum:
7019+
- StrategicMerge
7020+
- Merge
7021+
- JSONPatch
7022+
type: string
7023+
value:
7024+
description: |-
7025+
Value is the patch data as raw JSON.
7026+
For StrategicMerge and Merge patches, this should be a JSON object.
7027+
For JSONPatch patches, this should be a JSON array of patch operations.
7028+
x-kubernetes-preserve-unknown-fields: true
7029+
required:
7030+
- value
7031+
type: object
7032+
type: array
69557033
type:
69567034
default: LoadBalancer
69577035
description: ServiceType describes ingress method for the

0 commit comments

Comments
 (0)