[COMMON] Enhance ONAP common-service template - add IPv4/IPv6 support 69/121369/8
authorUbuntu <magdalena.1.biernacka@nokia.com>
Fri, 14 May 2021 09:02:30 +0000 (09:02 +0000)
committerSylvain Desbureaux <sylvain.desbureaux@orange.com>
Wed, 19 May 2021 14:20:47 +0000 (14:20 +0000)
Generic change for all common services by adding ipFamilyPolicy field.
Dual Stack service exposure will be provided depending on k8s version (v1.20+).

Signed-off-by: Magdalena Biernacka <magdalena.1.biernacka@nokia.com>
Issue-ID: OOM-2749
Change-Id: Ia7236705010e625c19a22e42ec9a02c9f75a0ec5

kubernetes/common/common/templates/_service.tpl

index 9c3010c..8489cc5 100644 (file)
@@ -181,6 +181,8 @@ labels: {{- include "common.labels" (dict "labels" $labels "dot" $dot) | nindent
 {{- $labels := default (dict) .labels -}}
 {{- $matchLabels := default (dict) .matchLabels -}}
 {{- $sessionAffinity := default "None" $dot.Values.service.sessionAffinity -}}
+{{- $kubeTargetVersion := default $dot.Capabilities.KubeVersion.Version | trimPrefix "v" -}}
+{{- $ipFamilyPolicy := default "PreferDualStack" $dot.Values.service.ipFamilyPolicy -}}
 apiVersion: v1
 kind: Service
 metadata: {{ include "common.serviceMetadata" (dict "suffix" $suffix "annotations" $annotations "msb_informations" $msb_informations "labels" $labels "dot" $dot) | nindent 2 }}
@@ -189,6 +191,9 @@ spec:
   clusterIP: None
   {{- end }}
   ports: {{- include "common.servicePorts" (dict "serviceType" $serviceType "ports" $ports "dot" $dot "add_plain_port" $add_plain_port) | nindent 4 }}
+  {{- if semverCompare ">=1.20.0" $kubeTargetVersion }}
+  ipFamilyPolicy: {{ $ipFamilyPolicy }}
+  {{- end }}
   {{- if $publishNotReadyAddresses }}
   publishNotReadyAddresses: true
   {{- end }}