8000 add globalConfigurationCustomName parameter (#8142) · nginx/kubernetes-ingress@1db0da2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1db0da2

Browse files
add globalConfigurationCustomName parameter (#8142)
1 parent 6b5ea85 commit 1db0da2

10 files changed

+583
-10
lines changed

charts/nginx-ingress/templates/_helpers.tpl

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,40 @@ false
213213
{{- end -}}
214214
{{- end -}}
215215

216+
{{/*
217+
Validate the globalConfiguration.customName value format.
218+
Ensures exactly one '/' separator for proper namespace/name parsing.
219+
*/}}
220+
{{- define "nginx-ingress.globalConfiguration.validateCustomName" -}}
221+
{{- if .Values.controller.globalConfiguration.customName }}
222+
{{- $parts := splitList "/" .Values.controller.globalConfiguration.customName }}
223+
{{- if ne (len $parts) 2 }}
224+
{{- fail "globalConfiguration.customName must contain exactly one '/' separator in namespace/name format (e.g., \"my-namespace/my-global-config\")" }}
225+
{{- end }}
226+
{{- if or (eq (index $parts 0) "") (eq (index $parts 1) "") }}
227+
{{- fail "globalConfiguration.customName namespace and name parts cannot be empty (e.g., \"my-namespace/my-global-config\")" }}
228+
{{- end }}
229+
{{- end }}
230+
{{- end -}}
231+
232+
{{/*
233+
Create the global configuration custom name from the globalConfiguration.customName value.
234+
*/}}
235+
{{- define "nginx-ingress.globalConfiguration.customName" -}}
236+
{{- include "nginx-ingress.globalConfiguration.validateCustomName" . -}}
237+
{{- $parts := splitList "/" .Values.controller.globalConfiguration.customName -}}
238+
{{- index $parts 1 -}}
239+
{{- end -}}
240+
241+
{{/*
242+
Create the global configuration custom namespace from the globalConfiguration.customName value.
243+
*/}}
244+
{{- define "nginx-ingress.globalConfiguration.customNamespace" -}}
245+
{{- include "nginx-ingress.globalConfiguration.validateCustomName" . -}}
246+
{{- $parts := splitList "/" .Values.controller.globalConfiguration.customName -}}
247+
{{- index $parts 0 -}}
248+
{{- end -}}
249+
216250
{{/*
217251
Build the args for the service binary.
218252
*/}}
@@ -314,8 +348,10 @@ Build the args for the service binary.
314348
- -enable-external-dns={{ .Values.controller.enableExternalDNS }}
315349
- -default-http-listener-port={{ .Values.controller.defaultHTTPListenerPort}}
316350
- -default-https-listener-port={{ .Values.controller.defaultHTTPSListenerPort}}
317-
{{- if .Values.controller.globalConfiguration.create }}
351+
{{- if and .Values.controller.globalConfiguration.create (not .Values.controller.globalConfiguration.customName) }}
318352
- -global-configuration=$(POD_NAMESPACE)/{{ include "nginx-ingress.controller.fullname" . }}
353+
{{- else if .Values.controller.globalConfiguration.customName }}
354+
- -global-configuration={{ .Values.controller.globalConfiguration.customName }}
319355
{{- end }}
320356
{{- end }}
321357
- -ready-status={{ .Values.controller.readyStatus.enable }}

charts/nginx-ingress/templates/controller-globalconfiguration.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22
apiVersion: k8s.nginx.org/v1
33
kind: GlobalConfiguration
44
metadata:
5+
{{- if not .Values.controller.globalConfiguration.customName }}
56
name: {{ include "nginx-ingress.controller.fullname" . }}
67
namespace: {{ .Release.Namespace }}
8+
{{- else }}
9+
name: {{ include "nginx-ingress.globalConfiguration.customName" . }}
10+
namespace: {{ include "nginx-ingress.globalConfiguration.customNamespace" . }}
11+
{{- end }}
712
labels:
813
{{- include "nginx-ingress.labels" . | nindent 4 }}
914
spec:

charts/nginx-ingress/values.schema.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,14 @@
11151115
false
11161116
]
11171117
},
1118+
"customName": {
1119+
"type": "string",
1120+
"default": "",
1121+
"title": "The customName Schema",
1122+
"examples": [
1123+
"the-namespace/the-name-of-the-global-configuration-custom-resource"
1124+
]
1125+
},
11181126
"spec": {
11191127
"type": "object",
11201128
"default": {},

charts/nginx-ingress/values.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,11 @@ controller:
407407
## Creates the GlobalConfiguration custom resource. Requires controller.enableCustomResources.
408408
create: false
409409

410+
## customName: "the-namespace/the-name-of-the-global-configuration-custom-resource"
411+
## The name of the GlobalConfiguration custom resource to use instead of the one provided by default.
412+
## Make sure the namespace is watched when watchNamespace or watchNamespaceLabel parameters are in use.
413+
customName: ""
414+
410415
## The spec of the GlobalConfiguration for defining the global configuration parameters of the Ingress Controller.
411416
spec: {} ## Ensure both curly brackets are removed when adding listeners in YAML format.
412417
# listeners:

0 commit comments

Comments
 (0)
0