From b79e90b19c26e9dff6a38b9cb254bdeb973ece38 Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Mon, 21 Aug 2023 10:05:23 -0700 Subject: [PATCH] Make containerPort and hostPort customizable (#4252) --- .../templates/controller-daemonset.yaml | 14 +++++---- .../templates/controller-deployment.yaml | 12 +++++--- deployments/helm-chart/values.schema.json | 29 +++++++++++++++++++ deployments/helm-chart/values.yaml | 18 ++++++++++++ 4 files changed, 63 insertions(+), 10 deletions(-) diff --git a/deployments/helm-chart/templates/controller-daemonset.yaml b/deployments/helm-chart/templates/controller-daemonset.yaml index 101529c391..a3d17a5a8d 100644 --- a/deployments/helm-chart/templates/controller-daemonset.yaml +++ b/deployments/helm-chart/templates/controller-daemonset.yaml @@ -85,12 +85,14 @@ spec: {{ toYaml .Values.controller.lifecycle | indent 10 }} {{- end }} ports: - - name: http - containerPort: 80 - hostPort: 80 - - name: https - containerPort: 443 - hostPort: 443 +{{- range $key, $value := .Values.controller.containerPort }} + - name: {{ $key }} + containerPort: {{ $value }} + protocol: TCP + {{- if and $.Values.controller.hostPort.enable (index $.Values.controller.hostPort $key) }} + hostPort: {{ index $.Values.controller.hostPort $key }} + {{- end }} +{{- end }} {{ if .Values.controller.customPorts }} {{ toYaml .Values.controller.customPorts | indent 8 }} {{ end }} diff --git a/deployments/helm-chart/templates/controller-deployment.yaml b/deployments/helm-chart/templates/controller-deployment.yaml index 07c4586385..8982b8c0fa 100644 --- a/deployments/helm-chart/templates/controller-deployment.yaml +++ b/deployments/helm-chart/templates/controller-deployment.yaml @@ -92,10 +92,14 @@ spec: {{ toYaml .Values.controller.lifecycle | indent 10 }} {{- end }} ports: - - name: http - containerPort: 80 - - name: https - containerPort: 443 +{{- range $key, $value := .Values.controller.containerPort }} + - name: {{ $key }} + containerPort: {{ $value }} + protocol: TCP + {{- if and $.Values.controller.hostPort.enable (index $.Values.controller.hostPort $key) }} + hostPort: {{ index $.Values.controller.hostPort $key }} + {{- end }} +{{- end }} {{- if .Values.controller.customPorts }} {{ toYaml .Values.controller.customPorts | indent 8 }} {{- end }} diff --git a/deployments/helm-chart/values.schema.json b/deployments/helm-chart/values.schema.json index e10d6dded6..dd43083a78 100644 --- a/deployments/helm-chart/values.schema.json +++ b/deployments/helm-chart/values.schema.json @@ -187,6 +187,35 @@ true ] }, + "hostPort": { + "type": "object", + "default": {}, + "title": "The hostPort Schema", + "patternProperties": { + "^.*$": { + "anyOf": [ + { + "$ref": "https://raw.githubusercontent.com/nginxinc/kubernetes-json-schema/master/v1.27.4/_definitions.json#/definitions/io.k8s.api.core.v1.ContainerPort/properties/hostPort" + }, + { + "type": "boolean" + } + ] + } + }, + "additionalProperties": false + }, + "containerPort": { + "type": "object", + "default": {}, + "title": "The containerPort Schema", + "patternProperties": { + "^.*$": { + "$ref": "https://raw.githubusercontent.com/nginxinc/kubernetes-json-schema/master/v1.27.4/_definitions.json#/definitions/io.k8s.api.core.v1.ContainerPort/properties/containerPort" + } + }, + "additionalProperties": false + }, "dnsPolicy": { "type": "string", "allOf": [ diff --git a/deployments/helm-chart/values.yaml b/deployments/helm-chart/values.yaml index 5f04539d81..531af909af 100644 --- a/deployments/helm-chart/values.yaml +++ b/deployments/helm-chart/values.yaml @@ -40,6 +40,24 @@ controller: ## Enables the Ingress Controller pods to use the host's network namespace. hostNetwork: false + ## The hostPort configuration for the Ingress Controller pods. + hostPort: + ## Enables hostPort for the Ingress Controller pods. + enable: false + + ## The HTTP hostPort configuration for the Ingress Controller pods. + http: 80 + + ## The HTTPS hostPort configuration for the Ingress Controller pods. + https: 443 + + containerPort: + ## The HTTP containerPort configuration for the Ingress Controller pods. + http: 80 + + ## The HTTPS containerPort configuration for the Ingress Controller pods. + https: 443 + ## DNS policy for the Ingress Controller pods dnsPolicy: ClusterFirst