From c21cf6826872c1e85a6a2651088d5166f54d3e5f Mon Sep 17 00:00:00 2001 From: Andrey Izotikov Date: Wed, 11 Sep 2019 00:40:46 +0300 Subject: [PATCH] [stable/nginx-ingress] Add substitution for containerPorts from values (#17037) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [stable/nginx-ingress] Add substitution for containerPorts from values Use key-value range from .Values.controller.containerPort definition instead of mapping 1to1 http and https ports. It allows passing extra configuration to nginx-ingress, such as validation-webhook with its own port, and define this port in values. Without this option it’s not possible because of hardcoded http and https ports in deployment/daemonset templates. Does not break anything. Signed-off-by: Andrey Izotikov * [stable/nginx-ingress] Bump version to 1.20.0 Signed-off-by: Andrey Izotikov --- stable/nginx-ingress/Chart.yaml | 2 +- .../templates/controller-daemonset.yaml | 17 +++++++---------- .../templates/controller-deployment.yaml | 9 ++++----- stable/nginx-ingress/values.yaml | 1 + 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/stable/nginx-ingress/Chart.yaml b/stable/nginx-ingress/Chart.yaml index 7049cbac7d8e..955921813ea7 100644 --- a/stable/nginx-ingress/Chart.yaml +++ b/stable/nginx-ingress/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 name: nginx-ingress -version: 1.19.1 +version: 1.20.0 appVersion: 0.25.1 home: https://github.com/kubernetes/ingress-nginx description: An nginx Ingress controller that uses ConfigMap to store the nginx configuration. diff --git a/stable/nginx-ingress/templates/controller-daemonset.yaml b/stable/nginx-ingress/templates/controller-daemonset.yaml index dfdf0b0b7a9b..70afafdea68c 100644 --- a/stable/nginx-ingress/templates/controller-daemonset.yaml +++ b/stable/nginx-ingress/templates/controller-daemonset.yaml @@ -1,5 +1,6 @@ {{- if or (eq .Values.controller.kind "DaemonSet") (eq .Values.controller.kind "Both") }} {{- $useHostPort := .Values.controller.daemonset.useHostPort -}} +{{- $hostPorts := .Values.controller.daemonset.hostPorts -}} apiVersion: extensions/v1beta1 kind: DaemonSet metadata: @@ -120,18 +121,14 @@ spec: successThreshold: {{ .Values.controller.livenessProbe.successThreshold }} failureThreshold: {{ .Values.controller.livenessProbe.failureThreshold }} ports: - - name: http - containerPort: {{ .Values.controller.containerPort.http }} + {{- range $key, $value := .Values.controller.containerPort }} + - name: {{ $key }} + containerPort: {{ $value }} protocol: TCP - {{- if .Values.controller.daemonset.useHostPort }} - hostPort: {{ .Values.controller.daemonset.hostPorts.http }} - {{- end }} - - name: https - containerPort: {{ .Values.controller.containerPort.https }} - protocol: TCP - {{- if .Values.controller.daemonset.useHostPort }} - hostPort: {{ .Values.controller.daemonset.hostPorts.https }} + {{- if $useHostPort }} + hostPort: {{ index $hostPorts $key | default $value }} {{- end }} + {{- end }} {{- if .Values.controller.metrics.enabled }} - name: metrics containerPort: 10254 diff --git a/stable/nginx-ingress/templates/controller-deployment.yaml b/stable/nginx-ingress/templates/controller-deployment.yaml index f9aad9ee86b9..185bfbdb9626 100644 --- a/stable/nginx-ingress/templates/controller-deployment.yaml +++ b/stable/nginx-ingress/templates/controller-deployment.yaml @@ -120,12 +120,11 @@ spec: successThreshold: {{ .Values.controller.livenessProbe.successThreshold }} failureThreshold: {{ .Values.controller.livenessProbe.failureThreshold }} ports: - - name: http - containerPort: {{ .Values.controller.containerPort.http }} - protocol: TCP - - name: https - containerPort: {{ .Values.controller.containerPort.https }} + {{- range $key, $value := .Values.controller.containerPort }} + - name: {{ $key }} + containerPort: {{ $value }} protocol: TCP + {{- end }} {{- if .Values.controller.metrics.enabled }} - name: metrics containerPort: 10254 diff --git a/stable/nginx-ingress/values.yaml b/stable/nginx-ingress/values.yaml index 16819d5d6328..71609d5f47a1 100644 --- a/stable/nginx-ingress/values.yaml +++ b/stable/nginx-ingress/values.yaml @@ -15,6 +15,7 @@ controller: containerPort: http: 80 https: 443 + # Will add custom configuration options to Nginx https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/ config: {}