From 4b266d74b2a50f0efb6f6724f541ffa92d33bde8 Mon Sep 17 00:00:00 2001 From: Stavros kois Date: Thu, 24 Nov 2022 18:33:27 +0200 Subject: [PATCH] expand service a bit --- .../common/1.0.0/templates/class/_service.tpl | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/library/common/1.0.0/templates/class/_service.tpl b/library/common/1.0.0/templates/class/_service.tpl index a8d973e6..dce22051 100644 --- a/library/common/1.0.0/templates/class/_service.tpl +++ b/library/common/1.0.0/templates/class/_service.tpl @@ -37,8 +37,8 @@ metadata: spec: {{- if eq $svcType "ClusterIP" }} {{/* ClusterIP */}} type: {{ $svcType }} - {{- if $svcValues.clusterIP }} - clusterIP: {{ $svcValues.clusterIP }} + {{- with $svcValues.clusterIP }} + clusterIP: {{ . }} {{- end }} {{- else if eq $svcType "NodePort" -}} {{/* NodePort */}} type: {{ $svcType }} @@ -56,8 +56,15 @@ spec: - {{ tpl . $root }} {{- end }} {{- end }} -{{- else if eq $svcType "ExternalIP" -}} {{/* ExternalIP */}} - {{/*TODO: */}} + {{- if $svcValues.externalTrafficPolicy -}} + {{- if not (has $svcValues.externalTrafficPolicy (list "Cluster" "Local")) -}} + {{- fail (printf "Invalid option (%s) for . Valid options are Cluster and Local" $svcValues) -}} + {{- end }} + externalTrafficPolicy: {{ $svcValues.externalTrafficPolicy }} + {{- end -}} + {{- with $svcValues.sessionAffinity }} + sessionAffinity: {{ . }} + {{- end -}} {{- end -}} ports: {{- range $name, $port := $svcValues.ports }} @@ -74,7 +81,7 @@ ports: protocol: TCP {{- end }} name: {{ $name }} - {{- if (and (eq $svcType "NodePort") (not (empty $port.nodePort))) }} + {{- if (and $port.nodePort (eq $svcType "NodePort")) }} nodePort: {{ $port.nodePort }} {{- end }} {{- end -}}