allow to override metallb shared key

This commit is contained in:
Stavros kois
2023-01-10 13:21:12 +02:00
parent d38edf34fc
commit dce096847a
2 changed files with 28 additions and 4 deletions

View File

@@ -230,6 +230,26 @@ tests:
some_key: value
some_key1: value1
- it: should pass with addAnnotations set to true and overridden metalLBSharedKey
documentIndex: *serviceDoc
set:
addAnnotations:
traefik: true
metallb: true
service:
main:
type: LoadBalancer
metalLBSharedKey: custom-shared-key
ports:
main:
protocol: HTTPS
asserts:
- equal:
path: metadata.annotations
value:
traefik.ingress.kubernetes.io/service.serversscheme: https
metallb.universe.tf/allow-shared-ip: custom-shared-key
- it: should pass with labels
documentIndex: *serviceDoc
set:

View File

@@ -32,13 +32,17 @@ metadata:
{{- with (include "ix.v1.common.util.labels.render" (dict "root" $root "labels" $labels) | trim) }}
labels:
{{- . | nindent 4 }}
{{- end }}
{{- end -}}
{{- $additionalAnnotations := dict -}}
{{- if and $root.Values.addAnnotations.traefik (eq ($primaryPort.protocol | default "") "HTTPS") }}
{{- if and $root.Values.addAnnotations.traefik (eq ($primaryPort.protocol | default "") "HTTPS") -}}
{{- $_ := set $additionalAnnotations "traefik.ingress.kubernetes.io/service.serversscheme" "https" -}}
{{- end -}}
{{- if and $root.Values.addAnnotations.metallb (eq $svcType "LoadBalancer") }}
{{- $_ := set $additionalAnnotations "metallb.universe.tf/allow-shared-ip" (include "ix.v1.common.names.fullname" $root) }}
{{- if and $root.Values.addAnnotations.metallb (eq $svcType "LoadBalancer") -}}
{{- $sharedLBKey := include "ix.v1.common.names.fullname" $root -}}
{{- with $svcValues.metalLBSharedKey -}}
{{- $sharedLBKey = tpl . $root -}}
{{- end -}}
{{- $_ := set $additionalAnnotations "metallb.universe.tf/allow-shared-ip" $sharedLBKey -}}
{{- end -}}
{{- $annotations := (mustMerge ($svcValues.annotations | default dict) (include "ix.v1.common.annotations" $root | fromYaml) $additionalAnnotations) -}}
{{- with (include "ix.v1.common.util.annotations.render" (dict "root" $root "annotations" $annotations) | trim) }}