Skip to content

Commit 8490da9

Browse files
committed
Helm: add globalConfigurationCustomName parameter
Extend globalConfiguration customName functionality when gc create true (nginx#6679)
1 parent ae76aea commit 8490da9

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

charts/nginx-ingress/templates/_helpers.tpl

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

216+
{{/*
217+
Create the global configuration custom name from the globalConfiguration.customName value.
218+
*/}}
219+
{{- define "nginx-ingress.globalConfiguration.customName" -}}
220+
{{ splitList "/" .Values.controller.globalConfiguration.customName | last }}
221+
{{- end -}}
222+
223+
{{/*
224+
Create the global configuration custom namespace from the globalConfiguration.customName value.
225+
*/}}
226+
{{- define "nginx-ingress.globalConfiguration.customNamespace" -}}
227+
{{ splitList "/" .Values.controller.globalConfiguration.customName | first }}
228+
{{- end -}}
229+
216230
{{/*
217231
Build the args for the service binary.
218232
*/}}
@@ -314,7 +328,7 @@ Build the args for the service binary.
314328
- -enable-external-dns={{ .Values.controller.enableExternalDNS }}
315329
- -default-http-listener-port={{ .Values.controller.defaultHTTPListenerPort}}
316330
- -default-https-listener-port={{ .Values.controller.defaultHTTPSListenerPort}}
317-
{{- if .Values.controller.globalConfiguration.create }}
331+
{{- if and .Values.controller.globalConfiguration.create (not .Values.controller.globalConfiguration.customName) }}
318332
- -global-configuration=$(POD_NAMESPACE)/{{ include "nginx-ingress.controller.fullname" . }}
319333
{{- else }}
320334
{{- if .Values.controller.globalConfiguration.customName }}

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:

0 commit comments

Comments
 (0)