[COMMON] Disable Nodeports in _service template
[oom.git] / kubernetes / common / common / templates / _service.tpl
index 49f1b94..379992e 100644 (file)
@@ -241,6 +241,9 @@ spec:
 {{-   $both_tls_and_plain:= default false $dot.Values.service.both_tls_and_plain }}
 {{-   $labels := default (dict) .labels -}}
 {{-   $matchLabels := default (dict) .matchLabels -}}
+{{-   if and (include "common.onServiceMesh" $dot) (eq $serviceType "NodePort") }}
+{{-   $serviceType = "ClusterIP" }}
+{{-   end }}
 
 {{-   if (and (include "common.needTLS" $dot) $both_tls_and_plain) }}
 {{      include "common.genericService" (dict "suffix" $suffix "annotations" $annotations "msb_informations" $msb_informations "dot" $dot "publishNotReadyAddresses" $publishNotReadyAddresses "ports" $ports "serviceType" "ClusterIP" "add_plain_port" true $labels "matchLabels" $matchLabels) }}
@@ -267,6 +270,11 @@ spec:
 {{- $ports := $dot.Values.service.headlessPorts -}}
 {{- $labels := default (dict) .labels -}}
 {{- $matchLabels := default (dict) .matchLabels -}}
+{{- if ($dot.Values.metrics) }}
+{{-   range $index, $metricPort := $dot.Values.metrics.ports }}
+{{-     $ports = append $ports $metricPort }}
+{{-   end }}
+{{- end }}
 {{ include "common.genericService" (dict "suffix" $suffix "annotations" $annotations "dot" $dot "publishNotReadyAddresses" $publishNotReadyAddresses "ports" $ports "serviceType" "ClusterIP" "headless" true "labels" $labels "matchLabels" $matchLabels) }}
 {{- end -}}
 
@@ -323,6 +331,16 @@ true
 {{-   end }}
 {{- end -}}
 
+{{/*
+  generate needed scheme:
+    - https if needTLS
+    - http if not
+*/}}
+
+{{- define "common.scheme" -}}
+  {{- ternary "https" "http" (eq "true" (include "common.needTLS" .)) }}
+{{- end -}}
+
 {{- define "common.port.buildCache" -}}
   {{- $global := . }}
   {{- if not $global.Values._DmaapDrNodePortsCache }}