From db3537e56b182a54e7f6931ce57e2a190714019b Mon Sep 17 00:00:00 2001 From: Sergiy Markin Date: Fri, 29 Sep 2023 17:13:16 +0000 Subject: [PATCH] [ingress-controller] Redesigned controller parameters This PS consolidates control over ingress class name and controller class names at one place. Change-Id: I394ec99e0e6177c8c8553b636e3fda90c967c15b --- ingress/Chart.yaml | 2 +- .../templates/bin/_ingress-controller.sh.tpl | 2 ++ ingress/templates/deployment-ingress.yaml | 25 ++++++------------- ingress/values.yaml | 18 +------------ .../ingress-class-cluster.yaml | 7 ++++++ .../ingress-class-namespaced.yaml | 13 +++++----- releasenotes/notes/ingress.yaml | 1 + 7 files changed, 26 insertions(+), 42 deletions(-) create mode 100644 ingress/values_overrides/ingress-class-cluster.yaml diff --git a/ingress/Chart.yaml b/ingress/Chart.yaml index fac53330b..8e422c6b8 100644 --- a/ingress/Chart.yaml +++ b/ingress/Chart.yaml @@ -15,7 +15,7 @@ apiVersion: v1 appVersion: v1.5.1 description: OpenStack-Helm Ingress Controller name: ingress -version: 0.2.17 +version: 0.2.18 home: https://github.com/kubernetes/ingress sources: - https://github.com/kubernetes/ingress diff --git a/ingress/templates/bin/_ingress-controller.sh.tpl b/ingress/templates/bin/_ingress-controller.sh.tpl index 23b189508..ee9e85eab 100644 --- a/ingress/templates/bin/_ingress-controller.sh.tpl +++ b/ingress/templates/bin/_ingress-controller.sh.tpl @@ -46,7 +46,9 @@ function start () { --election-id=${RELEASE_NAME} \ --controller-class=${CONTROLLER_CLASS} \ --ingress-class=${INGRESS_CLASS} \ + {{- if .Values.deployment.cluster.ingressClassByName }} --ingress-class-by-name=${INGRESS_CLASS_BY_NAME} \ + {{- end }} --default-backend-service=${POD_NAMESPACE}/${ERROR_PAGE_SERVICE} \ {{- if .Values.conf.default_ssl_certificate.enabled }} {{- $ns := .Values.conf.default_ssl_certificate.namespace | default .Release.Namespace }} diff --git a/ingress/templates/deployment-ingress.yaml b/ingress/templates/deployment-ingress.yaml index c1b2c82b7..b8a2ea77b 100644 --- a/ingress/templates/deployment-ingress.yaml +++ b/ingress/templates/deployment-ingress.yaml @@ -15,22 +15,6 @@ limitations under the License. {{- if .Values.manifests.deployment_ingress }} {{- $envAll := . }} -# Evaluate if we are deploying in cluster mode -{{- if eq .Values.deployment.mode "cluster" }} -# Check INGRESS_CLASS empty -{{- if empty .Values.conf.controller.INGRESS_CLASS -}} -{{- $_ := set .Values.conf.controller "INGRESS_CLASS" .Values.deployment.cluster.class -}} -{{- end }} -# Check CONTROLLER_CLASS empty -{{- if empty .Values.conf.controller.CONTROLLER_CLASS -}} -{{- $_ := set .Values.conf.controller "CONTROLLER_CLASS" .Values.deployment.cluster.controllerClass -}} -{{- end }} -# Set default values for INGRESS_CLASS & CONTROLLER_CLASS if deploying in namespace mode -{{- else if eq .Values.deployment.mode "namespace" }} -{{- $_ := set .Values.conf.controller "INGRESS_CLASS" "nginx" -}} -{{- $_ := set .Values.conf.controller "CONTROLLER_CLASS" "k8s.io/nginx-ingress" -}} -{{- end }} - {{- $serviceAccountName := printf "%s-%s" .Release.Name "ingress" }} {{ tuple $envAll "ingress" $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} --- @@ -322,7 +306,14 @@ spec: value: {{ .Release.Name | quote }} - name: ERROR_PAGE_SERVICE value: {{ tuple "ingress" "error_pages" . | include "helm-toolkit.endpoints.hostname_short_endpoint_lookup" | quote }} -{{ include "helm-toolkit.utils.to_k8s_env_vars" .Values.conf.controller | indent 12 }} + - name: INGRESS_CLASS + value: "{{ .Values.deployment.cluster.class }}" + {{- if .Values.deployment.cluster.ingressClassByName }} + - name: INGRESS_CLASS_BY_NAME + value: "{{ .Values.deployment.cluster.ingressClassByName }}" + {{- end }} + - name: CONTROLLER_CLASS + value: "{{ .Values.deployment.cluster.controllerClass }}" ports: - containerPort: {{ tuple "ingress" "internal" "http" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} {{- if .Values.network.host_namespace }} diff --git a/ingress/values.yaml b/ingress/values.yaml index 46f2b5ad4..a37af3fbb 100644 --- a/ingress/values.yaml +++ b/ingress/values.yaml @@ -21,6 +21,7 @@ deployment: type: Deployment cluster: class: "nginx-cluster" + ingressClassByName: false controllerClass: "k8s.io/nginx-ingress" images: @@ -308,23 +309,6 @@ secrets: dhparam: secret_dhparam: | conf: - controller: - # NOTE: if left blank this is populated from - # .deployment.cluster.class in cluster mode, or set to - # "nginx" in namespace mode - # [IN DEPRECATION] Name of the ingress class this controller satisfies. - # The class of an Ingress object is set using the annotation "kubernetes.io/ingress.class" (deprecated). - # The parameter --controller-class has precedence over this. (default "nginx") - INGRESS_CLASS: null - # Define if Ingress Controller should watch for Ingress Class by Name together with Controller Class - INGRESS_CLASS_BY_NAME: true - # NOTE: if left blank this is populated from - # .deployment.cluster.controllerClass in cluster mode, or set to - # "k8s.io/nginx-ingress" in namespace mode - # Ingress Class Controller value this Ingress satisfies. - # The class of an Ingress object is set using the field IngressClassName in Kubernetes clusters version v1.19.0 or higher. The .spec.controller value of the IngressClass - # referenced in an Ingress Object should be the same value specified here to make this object be watched. (default "k8s.io/ingress-nginx") - CONTROLLER_CLASS: null ingress: enable-underscores-in-headers: "true" # NOTE(portdirect): if left blank this is populated from diff --git a/ingress/values_overrides/ingress-class-cluster.yaml b/ingress/values_overrides/ingress-class-cluster.yaml new file mode 100644 index 000000000..eb422c89b --- /dev/null +++ b/ingress/values_overrides/ingress-class-cluster.yaml @@ -0,0 +1,7 @@ +--- +deployment: + mode: cluster + type: DaemonSet +network: + host_namespace: true +... diff --git a/ingress/values_overrides/ingress-class-namespaced.yaml b/ingress/values_overrides/ingress-class-namespaced.yaml index 0831a62d4..96c8f95ff 100644 --- a/ingress/values_overrides/ingress-class-namespaced.yaml +++ b/ingress/values_overrides/ingress-class-namespaced.yaml @@ -1,9 +1,8 @@ --- -conf: - ingress: - proxy-body-size: 20m - controller: - INGRESS_CLASS: ucp-ingress - INGRESS_CLASS_BY_NAME: true - CONTROLLER_CLASS: k8s.io/ucp-ingress +deployment: + mode: namespace + type: Deployment + cluster: + class: "ucp-ingress" + controllerClass: "k8s.io/ucp-ingress" ... diff --git a/releasenotes/notes/ingress.yaml b/releasenotes/notes/ingress.yaml index 4af952044..f068f44fe 100644 --- a/releasenotes/notes/ingress.yaml +++ b/releasenotes/notes/ingress.yaml @@ -21,4 +21,5 @@ ingress: - 0.2.15 Update kubernetes registry to registry.k8s.io - 0.2.16 Updated deprecated IngressClass annotation - 0.2.17 Fixed controller parameters + - 0.2.18 Fixed some additional controller issues ...