From f3e1fa4e729ad8e44e8366ce3ed8d6593848bb6f Mon Sep 17 00:00:00 2001
From: Pete Birley <pete@port.direct>
Date: Tue, 20 Nov 2018 09:57:56 -0600
Subject: [PATCH] Ingress: Allow status port to be customised

This PS updates the ingress chart to allow the status pport to be
changed.

Change-Id: Ia38223c56806f6113622a809e792b4fedd010d87
Signed-off-by: Pete Birley <pete@port.direct>
---
 ingress/templates/bin/_ingress-controller.sh.tpl | 1 +
 ingress/templates/deployment-ingress.yaml        | 6 ++++++
 ingress/templates/service-ingress.yaml           | 4 ++++
 ingress/values.yaml                              | 2 ++
 4 files changed, 13 insertions(+)

diff --git a/ingress/templates/bin/_ingress-controller.sh.tpl b/ingress/templates/bin/_ingress-controller.sh.tpl
index 6514ae59c..b041062e8 100644
--- a/ingress/templates/bin/_ingress-controller.sh.tpl
+++ b/ingress/templates/bin/_ingress-controller.sh.tpl
@@ -27,6 +27,7 @@ function start () {
       {{- end }}
       --http-port=${PORT_HTTP} \
       --https-port=${PORT_HTTPS} \
+      --status-port=${PORT_STATUS} \
       --election-id=${RELEASE_NAME} \
       --ingress-class=${INGRESS_CLASS} \
       --default-backend-service=${POD_NAMESPACE}/${ERROR_PAGE_SERVICE} \
diff --git a/ingress/templates/deployment-ingress.yaml b/ingress/templates/deployment-ingress.yaml
index e388b7cd6..7cdfbf954 100644
--- a/ingress/templates/deployment-ingress.yaml
+++ b/ingress/templates/deployment-ingress.yaml
@@ -255,6 +255,8 @@ spec:
               value: {{ tuple "ingress" "internal" "http" . | include "helm-toolkit.endpoints.endpoint_port_lookup" | quote }}
             - name: PORT_HTTPS
               value: {{ tuple "ingress" "internal" "https" . | include "helm-toolkit.endpoints.endpoint_port_lookup" | quote }}
+            - name: PORT_STATUS
+              value: {{ tuple "ingress" "internal" "status" . | include "helm-toolkit.endpoints.endpoint_port_lookup" | quote }}
             - name: RELEASE_NAME
               value: {{ .Release.Name | quote }}
             - name: ERROR_PAGE_SERVICE
@@ -269,6 +271,10 @@ spec:
             {{- if .Values.network.host_namespace }}
               hostPort: {{ tuple "ingress" "internal" "https" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
             {{- end }}
+            - containerPort: {{ tuple "ingress" "internal" "status" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
+            {{- if .Values.network.host_namespace }}
+              hostPort: {{ tuple "ingress" "internal" "status" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
+            {{- end }}
           command:
             - /tmp/ingress-controller.sh
             - start
diff --git a/ingress/templates/service-ingress.yaml b/ingress/templates/service-ingress.yaml
index ca9af8ce2..686e4f76e 100644
--- a/ingress/templates/service-ingress.yaml
+++ b/ingress/templates/service-ingress.yaml
@@ -39,6 +39,10 @@ spec:
     port: {{ tuple "ingress" "internal" "https" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
     protocol: TCP
     targetPort: {{ tuple "ingress" "internal" "https" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
+  - name: status
+    port: {{ tuple "ingress" "internal" "status" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
+    protocol: TCP
+    targetPort: {{ tuple "ingress" "internal" "status" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
   {{- if not (empty $envAll.Values.conf.services.tcp) }}
   {{range $key, $value := $envAll.Values.conf.services.tcp -}}
   - name: {{ cat ((( $value | split "/" )._1 | split ":" )._0  | trunc 8 ) $key | nospace | quote }}
diff --git a/ingress/values.yaml b/ingress/values.yaml
index 7d1568760..1a694c1b4 100644
--- a/ingress/values.yaml
+++ b/ingress/values.yaml
@@ -162,6 +162,8 @@ endpoints:
         default: 80
       https:
         default: 443
+      status:
+        default: 18080
   ingress_exporter:
     namespace: null
     hosts: