diff --git a/charts/nginx-ingress/templates/_helpers.tpl b/charts/nginx-ingress/templates/_helpers.tpl index 7fe436cca..194df9d9c 100644 --- a/charts/nginx-ingress/templates/_helpers.tpl +++ b/charts/nginx-ingress/templates/_helpers.tpl @@ -213,6 +213,20 @@ false {{- end -}} {{- end -}} +{{/* +Create the global configuration custom name from the globalConfiguration.customName value. +*/}} +{{- define "nginx-ingress.globalConfiguration.customName" -}} +{{ splitList "/" .Values.controller.globalConfiguration.customName | last }} +{{- end -}} + +{{/* +Create the global configuration custom namespace from the globalConfiguration.customName value. +*/}} +{{- define "nginx-ingress.globalConfiguration.customNamespace" -}} +{{ splitList "/" .Values.controller.globalConfiguration.customName | first }} +{{- end -}} + {{/* Build the args for the service binary. */}} @@ -314,8 +328,12 @@ Build the args for the service binary. - -enable-external-dns={{ .Values.controller.enableExternalDNS }} - -default-http-listener-port={{ .Values.controller.defaultHTTPListenerPort}} - -default-https-listener-port={{ .Values.controller.defaultHTTPSListenerPort}} -{{- if .Values.controller.globalConfiguration.create }} +{{- if and .Values.controller.globalConfiguration.create (not .Values.controller.globalConfiguration.customName) }} - -global-configuration=$(POD_NAMESPACE)/{{ include "nginx-ingress.controller.fullname" . }} +{{- else }} +{{- if .Values.controller.globalConfiguration.customName }} +- -global-configuration={{ .Values.controller.globalConfiguration.customName }} +{{- end }} {{- end }} {{- end }} - -ready-status={{ .Values.controller.readyStatus.enable }} diff --git a/charts/nginx-ingress/templates/controller-globalconfiguration.yaml b/charts/nginx-ingress/templates/controller-globalconfiguration.yaml index 939923f2e..19df048a2 100644 --- a/charts/nginx-ingress/templates/controller-globalconfiguration.yaml +++ b/charts/nginx-ingress/templates/controller-globalconfiguration.yaml @@ -2,8 +2,13 @@ apiVersion: k8s.nginx.org/v1 kind: GlobalConfiguration metadata: +{{- if not .Values.controller.globalConfiguration.customName }} name: {{ include "nginx-ingress.controller.fullname" . }} namespace: {{ .Release.Namespace }} +{{- else }} + name: {{ include "nginx-ingress.globalConfiguration.customName" . }} + namespace: {{ include "nginx-ingress.globalConfiguration.customNamespace" . }} +{{- end }} labels: {{- include "nginx-ingress.labels" . | nindent 4 }} spec: diff --git a/charts/nginx-ingress/values.schema.json b/charts/nginx-ingress/values.schema.json index 1fe301a7e..9d1e8284f 100644 --- a/charts/nginx-ingress/values.schema.json +++ b/charts/nginx-ingress/values.schema.json @@ -1091,6 +1091,14 @@ false ] }, + "customName": { + "type": "string", + "default": "", + "title": "The customName Schema", + "examples": [ + "the-namespace/the-name-of-the-global-configuration-custom-resource" + ] + }, "spec": { "type": "object", "default": {}, diff --git a/charts/nginx-ingress/values.yaml b/charts/nginx-ingress/values.yaml index 09f89f295..156b442c6 100644 --- a/charts/nginx-ingress/values.yaml +++ b/charts/nginx-ingress/values.yaml @@ -395,6 +395,9 @@ controller: ## Creates the GlobalConfiguration custom resource. Requires controller.enableCustomResources. create: false + ## customName: "the-namespace/the-name-of-the-global-configuration-custom-resource" + ## The name of the GlobalConfiguration custom resource to use instead of the one provided by default. + ## The spec of the GlobalConfiguration for defining the global configuration parameters of the Ingress Controller. spec: {} ## Ensure both curly brackets are removed when adding listeners in YAML format. # listeners: