From 812e7ef688e320314ce5f3317887fb15a0d924cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Javier=20Tsao=20Sant=C3=ADn?= Date: Thu, 17 Oct 2024 17:29:58 +0200 Subject: [PATCH 1/8] Helm: add globalConfigurationCustomName parameter Add globalConfigurationCustomName parameter to controller configuration in helm chart (#6679) --- charts/nginx-ingress/templates/_helpers.tpl | 4 ++++ charts/nginx-ingress/values.schema.json | 8 ++++++++ charts/nginx-ingress/values.yaml | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/charts/nginx-ingress/templates/_helpers.tpl b/charts/nginx-ingress/templates/_helpers.tpl index 12b8aa70e9..79ae0ce4d6 100644 --- a/charts/nginx-ingress/templates/_helpers.tpl +++ b/charts/nginx-ingress/templates/_helpers.tpl @@ -291,6 +291,10 @@ Build the args for the service binary. - -default-https-listener-port={{ .Values.controller.defaultHTTPSListenerPort}} {{- if .Values.controller.globalConfiguration.create }} - -global-configuration=$(POD_NAMESPACE)/{{ include "nginx-ingress.controller.fullname" . }} +{{- else }} +{{- if .Values.controller.globalConfigurationCustomName }} +- -global-configuration={{ .Values.controller.globalConfigurationCustomName }} +{{- end }} {{- end }} {{- end }} - -ready-status={{ .Values.controller.readyStatus.enable }} diff --git a/charts/nginx-ingress/values.schema.json b/charts/nginx-ingress/values.schema.json index 0440ae6d52..bd798f0577 100644 --- a/charts/nginx-ingress/values.schema.json +++ b/charts/nginx-ingress/values.schema.json @@ -1042,6 +1042,14 @@ } ] }, + "globalConfigurationCustomName": { + "type": "string", + "default": "", + "title": "The globalConfigurationCustomName", + "examples": [ + "the-namespace/the-name-of-the-global-configuration-custom-resource" + ] + }, "enableSnippets": { "type": "boolean", "default": false, diff --git a/charts/nginx-ingress/values.yaml b/charts/nginx-ingress/values.yaml index 6ed8f0e216..bfc18cfab8 100644 --- a/charts/nginx-ingress/values.yaml +++ b/charts/nginx-ingress/values.yaml @@ -372,6 +372,10 @@ controller: # port: 5353 # protocol: TCP + ## globalConfigurationCustomName: "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 when controller.globalConfiguration.create is set to false. + ## See: https://github.com/nginxinc/kubernetes-ingress/tree/v3.6.2/examples/custom-resources/custom-listeners#prerequisites + ## Enable custom NGINX configuration snippets in Ingress, VirtualServer, VirtualServerRoute and TransportServer resources. enableSnippets: false From 1db8f4ad160016ffabaee293ecabef044dddeb14 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 17 Oct 2024 16:00:01 +0000 Subject: [PATCH 2/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- charts/nginx-ingress/values.schema.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/charts/nginx-ingress/values.schema.json b/charts/nginx-ingress/values.schema.json index bd798f0577..f3bdacde90 100644 --- a/charts/nginx-ingress/values.schema.json +++ b/charts/nginx-ingress/values.schema.json @@ -1042,14 +1042,14 @@ } ] }, - "globalConfigurationCustomName": { - "type": "string", - "default": "", - "title": "The globalConfigurationCustomName", - "examples": [ - "the-namespace/the-name-of-the-global-configuration-custom-resource" - ] - }, + "globalConfigurationCustomName": { + "type": "string", + "default": "", + "title": "The globalConfigurationCustomName", + "examples": [ + "the-namespace/the-name-of-the-global-configuration-custom-resource" + ] + }, "enableSnippets": { "type": "boolean", "default": false, From 548ac117465404466273083cbc3201592cac0094 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Javier=20Tsao=20Sant=C3=ADn?= Date: Thu, 17 Oct 2024 18:24:28 +0200 Subject: [PATCH 3/8] Remove unneeded comment in values.yaml --- charts/nginx-ingress/values.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/charts/nginx-ingress/values.yaml b/charts/nginx-ingress/values.yaml index bfc18cfab8..3638a05f80 100644 --- a/charts/nginx-ingress/values.yaml +++ b/charts/nginx-ingress/values.yaml @@ -374,7 +374,6 @@ controller: ## globalConfigurationCustomName: "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 when controller.globalConfiguration.create is set to false. - ## See: https://github.com/nginxinc/kubernetes-ingress/tree/v3.6.2/examples/custom-resources/custom-listeners#prerequisites ## Enable custom NGINX configuration snippets in Ingress, VirtualServer, VirtualServerRoute and TransportServer resources. enableSnippets: false From 610f49e23a770cb2b4f3df96c2a927d5db67741b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Javier=20Tsao=20Sant=C3=ADn?= Date: Tue, 19 Nov 2024 17:32:13 +0100 Subject: [PATCH 4/8] moved globalConfigurationCustomName parameter to globalConfiguration.customName --- charts/nginx-ingress/templates/_helpers.tpl | 4 ++-- charts/nginx-ingress/values.schema.json | 16 ++++++++-------- charts/nginx-ingress/values.yaml | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/charts/nginx-ingress/templates/_helpers.tpl b/charts/nginx-ingress/templates/_helpers.tpl index 79ae0ce4d6..2a2a995562 100644 --- a/charts/nginx-ingress/templates/_helpers.tpl +++ b/charts/nginx-ingress/templates/_helpers.tpl @@ -292,8 +292,8 @@ Build the args for the service binary. {{- if .Values.controller.globalConfiguration.create }} - -global-configuration=$(POD_NAMESPACE)/{{ include "nginx-ingress.controller.fullname" . }} {{- else }} -{{- if .Values.controller.globalConfigurationCustomName }} -- -global-configuration={{ .Values.controller.globalConfigurationCustomName }} +{{- if .Values.controller.globalConfiguration.customName }} +- -global-configuration={{ .Values.controller.globalConfiguration.customName }} {{- end }} {{- end }} {{- end }} diff --git a/charts/nginx-ingress/values.schema.json b/charts/nginx-ingress/values.schema.json index 9535c79624..aa6eb55a71 100644 --- a/charts/nginx-ingress/values.schema.json +++ b/charts/nginx-ingress/values.schema.json @@ -972,6 +972,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": {}, @@ -1042,14 +1050,6 @@ } ] }, - "globalConfigurationCustomName": { - "type": "string", - "default": "", - "title": "The globalConfigurationCustomName", - "examples": [ - "the-namespace/the-name-of-the-global-configuration-custom-resource" - ] - }, "enableSnippets": { "type": "boolean", "default": false, diff --git a/charts/nginx-ingress/values.yaml b/charts/nginx-ingress/values.yaml index 3638a05f80..42f529cefc 100644 --- a/charts/nginx-ingress/values.yaml +++ b/charts/nginx-ingress/values.yaml @@ -362,6 +362,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 when create is set to false. + ## 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: @@ -372,9 +375,6 @@ controller: # port: 5353 # protocol: TCP - ## globalConfigurationCustomName: "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 when controller.globalConfiguration.create is set to false. - ## Enable custom NGINX configuration snippets in Ingress, VirtualServer, VirtualServerRoute and TransportServer resources. enableSnippets: false From 0823d8d1efc9fea74f73633e7292c9fddfc2938d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 19 Nov 2024 16:32:35 +0000 Subject: [PATCH 5/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- charts/nginx-ingress/values.schema.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/charts/nginx-ingress/values.schema.json b/charts/nginx-ingress/values.schema.json index aa6eb55a71..9d98b6f99c 100644 --- a/charts/nginx-ingress/values.schema.json +++ b/charts/nginx-ingress/values.schema.json @@ -972,14 +972,14 @@ false ] }, - "customName": { - "type": "string", - "default": "", - "title": "The customName Schema", - "examples": [ - "the-namespace/the-name-of-the-global-configuration-custom-resource" - ] - }, + "customName": { + "type": "string", + "default": "", + "title": "The customName Schema", + "examples": [ + "the-namespace/the-name-of-the-global-configuration-custom-resource" + ] + }, "spec": { "type": "object", "default": {}, From 3969d8b5545f7a76c3dfeffb8a85b395f3f4e13f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Javier=20Tsao=20Sant=C3=ADn?= Date: Tue, 19 Nov 2024 17:38:06 +0100 Subject: [PATCH 6/8] Fix values.schema.json format --- charts/nginx-ingress/values.schema.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/charts/nginx-ingress/values.schema.json b/charts/nginx-ingress/values.schema.json index aa6eb55a71..9d98b6f99c 100644 --- a/charts/nginx-ingress/values.schema.json +++ b/charts/nginx-ingress/values.schema.json @@ -972,14 +972,14 @@ false ] }, - "customName": { - "type": "string", - "default": "", - "title": "The customName Schema", - "examples": [ - "the-namespace/the-name-of-the-global-configuration-custom-resource" - ] - }, + "customName": { + "type": "string", + "default": "", + "title": "The customName Schema", + "examples": [ + "the-namespace/the-name-of-the-global-configuration-custom-resource" + ] + }, "spec": { "type": "object", "default": {}, From 8490da9140d91eb97bef9991512ee46a968dc7ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Javier=20Tsao=20Sant=C3=ADn?= Date: Thu, 12 Dec 2024 15:00:20 +0100 Subject: [PATCH 7/8] Helm: add globalConfigurationCustomName parameter Extend globalConfiguration customName functionality when gc create true (#6679) --- charts/nginx-ingress/templates/_helpers.tpl | 16 +++++++++++++++- .../controller-globalconfiguration.yaml | 5 +++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/charts/nginx-ingress/templates/_helpers.tpl b/charts/nginx-ingress/templates/_helpers.tpl index b729a9e2f0..194df9d9c6 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,7 +328,7 @@ 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 }} diff --git a/charts/nginx-ingress/templates/controller-globalconfiguration.yaml b/charts/nginx-ingress/templates/controller-globalconfiguration.yaml index 939923f2e0..19df048a29 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: From f8681b7714b44484523b2271b6790c3913255c22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Javier=20Tsao=20Sant=C3=ADn?= Date: Thu, 12 Dec 2024 15:06:08 +0100 Subject: [PATCH 8/8] Helm: add globalConfigurationCustomName parameter Fix documentation in values.yaml (#6679) --- charts/nginx-ingress/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/nginx-ingress/values.yaml b/charts/nginx-ingress/values.yaml index f6f7bca2d7..ad96757678 100644 --- a/charts/nginx-ingress/values.yaml +++ b/charts/nginx-ingress/values.yaml @@ -396,7 +396,7 @@ controller: 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 when create is set to false. + ## 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.