[GENERAL] Allow different port for svc and pod 42/117642/3
authorSylvain Desbureaux <sylvain.desbureaux@orange.com>
Tue, 9 Feb 2021 13:59:21 +0000 (14:59 +0100)
committerKrzysztof Opasiak <k.opasiak@samsung.com>
Tue, 2 Mar 2021 18:47:51 +0000 (18:47 +0000)
Instead of having the exact same port number for service and container,
let's allow to use an internal port (usually > 1024) and a service port
(usually 80 or 443).

Issue-ID: OOM-2674
Signed-off-by: Sylvain Desbureaux <sylvain.desbureaux@orange.com>
Change-Id: Ib90073fc8b069fceed7666778ae0c7b8a8ffcdca

kubernetes/common/common/templates/_pod.tpl

index de25485..b38a7f1 100644 (file)
 {{- $global := . }}
 {{-   range $index, $port := $ports }}
 {{-     if (include "common.needTLS" $global) }}
-- containerPort: {{ $port.port }}
+- containerPort: {{ default $port.port $port.internal_port }}
 {{-     else }}
-- containerPort: {{ default $port.port $port.plain_port }}
+- containerPort: {{ default (default $port.port $port.internal_port) (default $port.plain_port $port.internal_plain_port) }}
 {{-     end }}
   name: {{ $port.name }}
 {{-     if (and $port.plain_port (and (include "common.needTLS" $global) $both_tls_and_plain))  }}
-- containerPort: {{ $port.plain_port }}
+- containerPort: {{ default $port.plain_port $port.internal_plain_port }}
   name: {{ $port.name }}-plain
 {{-     end }}
 {{-   end }}
@@ -67,4 +67,3 @@ securityContext:
   privileged: false
   allowPrivilegeEscalation: false
 {{- end }}
-