Skip to content

Commit b7c7c2d

Browse files
authored
Allow for provisioning NGINX as DaemonSet (#3397)
Problem: With the initial provisioner implementation, the NGINX gateway could only be installed as a Deployment. Users may want to install NGINX as a DaemonSet. Solution: Allow for provisioning the NGINX gateway as a DaemonSet.
1 parent f9fa98c commit b7c7c2d

File tree

31 files changed

+7389
-130
lines changed

31 files changed

+7389
-130
lines changed

apis/v1alpha2/nginxproxy_types.go

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,13 +359,22 @@ const (
359359
)
360360

361361
// KubernetesSpec contains the configuration for the NGINX Deployment and Service Kubernetes objects.
362+
//
363+
// +kubebuilder:validation:XValidation:message="only one of deployment or daemonSet can be set",rule="(!has(self.deployment) && !has(self.daemonSet)) || ((has(self.deployment) && !has(self.daemonSet)) || (!has(self.deployment) && has(self.daemonSet)))"
364+
//
365+
//nolint:lll
362366
type KubernetesSpec struct {
363367
// Deployment is the configuration for the NGINX Deployment.
364368
// This is the default deployment option.
365369
//
366370
// +optional
367371
Deployment *DeploymentSpec `json:"deployment,omitempty"`
368372

373+
// DaemonSet is the configuration for the NGINX DaemonSet.
374+
//
375+
// +optional
376+
DaemonSet *DaemonSetSpec `json:"daemonSet,omitempty"`
377+
369378
// Service is the configuration for the NGINX Service.
370379
//
371380
// +optional
@@ -382,12 +391,25 @@ type DeploymentSpec struct {
382391
// Pod defines Pod-specific fields.
383392
//
384393
// +optional
385-
Pod PodSpec `json:"pod,omitempty"`
394+
Pod PodSpec `json:"pod"`
395+
396+
// Container defines container fields for the NGINX container.
397+
//
398+
// +optional
399+
Container ContainerSpec `json:"container"`
400+
}
401+
402+
// DaemonSet is the configuration for the NGINX DaemonSet.
403+
type DaemonSetSpec struct {
404+
// Pod defines Pod-specific fields.
405+
//
406+
// +optional
407+
Pod PodSpec `json:"pod"`
386408

387409
// Container defines container fields for the NGINX container.
388410
//
389411
// +optional
390-
Container ContainerSpec `json:"container,omitempty"`
412+
Container ContainerSpec `json:"container"`
391413
}
392414

393415
// PodSpec defines Pod-specific fields.

apis/v1alpha2/zz_generated.deepcopy.go

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

charts/nginx-gateway-fabric/templates/clusterrole.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ rules:
1414
- serviceaccounts
1515
- services
1616
- deployments
17+
- daemonsets
1718
verbs:
1819
- create
1920
- update

charts/nginx-gateway-fabric/templates/nginxproxy.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,22 @@ spec:
2727
debug: {{ .Values.nginx.debug }}
2828
{{- end }}
2929
{{- end }}
30+
{{- if eq .Values.nginx.kind "daemonSet" }}
31+
daemonSet:
32+
{{- if .Values.nginx.pod }}
33+
pod:
34+
{{- toYaml .Values.nginx.pod | nindent 8 }}
35+
{{- end }}
36+
container:
37+
{{- if .Values.nginx.container }}
38+
{{- toYaml .Values.nginx.container | nindent 8 }}
39+
{{- end }}
40+
image:
41+
{{- toYaml .Values.nginx.image | nindent 10 }}
42+
{{- if .Values.nginx.debug }}
43+
debug: {{ .Values.nginx.debug }}
44+
{{- end }}
45+
{{- end }}
3046
{{- if .Values.nginx.service }}
3147
service:
3248
{{- with .Values.nginx.service }}

charts/nginx-gateway-fabric/values.schema.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,8 @@
337337
"default": "deployment",
338338
"description": "The kind of NGINX deployment.",
339339
"enum": [
340-
"deployment"
340+
"deployment",
341+
"daemonSet"
341342
],
342343
"required": [],
343344
"title": "kind"

charts/nginx-gateway-fabric/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ nginx:
185185
# @schema
186186
# enum:
187187
# - deployment
188+
# - daemonSet
188189
# @schema
189190
# -- The kind of NGINX deployment.
190191
kind: deployment

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

Lines changed: 3388 additions & 0 deletions
Large diffs are not rendered by default.

deploy/azure/deploy.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ rules:
6060
- serviceaccounts
6161
- services
6262
- deployments
63+
- daemonsets
6364
verbs:
6465
- create
6566
- update

deploy/crds.yaml

Lines changed: 3388 additions & 0 deletions
Large diffs are not rendered by default.

deploy/default/deploy.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ rules:
6060
- serviceaccounts
6161
- services
6262
- deployments
63+
- daemonsets
6364
verbs:
6465
- create
6566
- update

0 commit comments

Comments
 (0)