fix annotation for cni

This commit is contained in:
Stavros kois
2023-01-28 18:00:33 +02:00
parent 81aeb27bd9
commit 18155833a1
8 changed files with 20 additions and 25 deletions

View File

@@ -165,12 +165,12 @@ tests:
count: 4
- isKind:
of: Deployment
- isSubset:
- isNull:
path: metadata.annotations
- isSubset:
path: spec.template.metadata.annotations
content:
k8s.v1.cni.cncf.io/networks: ix-RELEASE-NAME-0
- isNull:
path: metadata.annotations.rollme
- matchRegex:
path: spec.template.metadata.annotations.rollme
pattern: "^[a-zA-Z0-9]{5}$"
@@ -254,12 +254,12 @@ tests:
count: 5
- isKind:
of: Deployment
- isSubset:
- isNull:
path: metadata.annotations
- isSubset:
path: spec.template.metadata.annotations
content:
k8s.v1.cni.cncf.io/networks: ix-RELEASE-NAME-0, ix-RELEASE-NAME-1
- isNull:
path: metadata.annotations.rollme
- matchRegex:
path: spec.template.metadata.annotations.rollme
pattern: "^[a-zA-Z0-9]{5}$"

View File

@@ -25,7 +25,7 @@ metadata:
labels:
{{- . | nindent 4 }}
{{- end }}
{{- $annotations := (mustMerge ($job.annotations | default dict) (include "ix.v1.common.annotations" $root | fromYaml) (include "ix.v1.common.podAnnotations" $root | fromYaml) (include "ix.v1.common.annotations.workload.spec" $root | fromYaml)) -}}
{{- $annotations := (mustMerge ($job.annotations | default dict) (include "ix.v1.common.annotations" $root | fromYaml) (include "ix.v1.common.podAnnotations" $root | fromYaml)) -}}
{{- with (include "ix.v1.common.util.annotations.render" (dict "root" $root "annotations" $annotations) | trim) }}
annotations:
{{- . | nindent 4 }}

View File

@@ -12,7 +12,7 @@ metadata:
labels:
{{- . | nindent 4 }}
{{- end }}
{{- $annotations := (mustMerge ($job.annotations | default dict) (include "ix.v1.common.annotations" $root | fromYaml) (include "ix.v1.common.podAnnotations" $root | fromYaml) (include "ix.v1.common.annotations.workload.spec" $root | fromYaml)) -}}
{{- $annotations := (mustMerge ($job.annotations | default dict) (include "ix.v1.common.annotations" $root | fromYaml) (include "ix.v1.common.podAnnotations" $root | fromYaml)) -}}
{{- with (include "ix.v1.common.util.annotations.render" (dict "root" $root "annotations" $annotations) | trim) }}
annotations:
{{- . | nindent 4 }}

View File

@@ -8,24 +8,17 @@ Rendered under ".metadata.annotations"
{{- include "ix.v1.common.util.annotations.render" (dict "root" . "annotations" .Values.global.annotations) -}}
{{- end -}}
{{/*
These annotations will be applied to all "workload" "spec" objects
Rendered under ".spec.template.metadata.annotations"
*/}}
{{- define "ix.v1.common.annotations.workload.spec" -}}
{{- if .Values.ixExternalInterfacesConfiguration -}}
{{- if .Values.ixExternalInterfacesConfigurationNames }}
k8s.v1.cni.cncf.io/networks: {{ join ", " .Values.ixExternalInterfacesConfigurationNames }}
{{- else -}}
{{- fail "There are externalInterfaces defined, but key <ixExternalInterfaceConfigurationNames> is empty." -}}
{{- end }}
{{- end -}}
{{- end -}}
{{/*
These annotations will be applied to all "workload" objects
Rendered under ".metadata.annotations"
*/}}
{{- define "ix.v1.common.annotations.workload" -}}
rollme: {{ randAlphaNum 5 | quote }}
{{- if .Values.ixExternalInterfacesConfiguration }}
{{- if .Values.ixExternalInterfacesConfigurationNames }}
k8s.v1.cni.cncf.io/networks: {{ join ", " .Values.ixExternalInterfacesConfigurationNames }}
{{- else -}}
{{- fail "There are externalInterfaces defined, but key <ixExternalInterfaceConfigurationNames> is empty." -}}
{{- end }}
{{- end -}}
{{- end -}}

View File

@@ -15,4 +15,6 @@ helm-revision: {{ .Release.Revision | quote }}
{{- define "ix.v1.common.labels.selectorLabels" -}}
app.kubernetes.io/name: {{ include "ix.v1.common.names.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app: {{ include "ix.v1.common.names.name" . }}
release: {{ .Release.Name }}
{{- end -}}

View File

@@ -13,7 +13,7 @@ metadata:
labels:
{{- . | nindent 4 }}
{{- end }}
{{- $annotations := (mustMerge (default dict .Values.controller.annotations) (include "ix.v1.common.annotations" $ | fromYaml) (include "ix.v1.common.annotations.workload.spec" $ | fromYaml)) -}}
{{- $annotations := (mustMerge (default dict .Values.controller.annotations) (include "ix.v1.common.annotations" $ | fromYaml)) -}}
{{- with (include "ix.v1.common.util.annotations.render" (dict "root" $ "annotations" $annotations) | trim) }}
annotations:
{{- . | nindent 4 }}

View File

@@ -13,7 +13,7 @@ metadata:
labels:
{{- . | nindent 4 }}
{{- end }}
{{- $annotations := (mustMerge (default dict .Values.controller.annotations) (include "ix.v1.common.annotations" $ | fromYaml) (include "ix.v1.common.annotations.workload.spec" $ | fromYaml)) -}}
{{- $annotations := (mustMerge (default dict .Values.controller.annotations) (include "ix.v1.common.annotations" $ | fromYaml)) -}}
{{- with (include "ix.v1.common.util.annotations.render" (dict "root" $ "annotations" $annotations) | trim) }}
annotations:
{{- . | nindent 4 }}

View File

@@ -13,7 +13,7 @@ metadata:
labels:
{{- . | nindent 4 }}
{{- end }}
{{- $annotations := (mustMerge (default dict .Values.controller.annotations) (include "ix.v1.common.annotations" $ | fromYaml) (include "ix.v1.common.annotations.workload.spec" $ | fromYaml)) -}}
{{- $annotations := (mustMerge (default dict .Values.controller.annotations) (include "ix.v1.common.annotations" $ | fromYaml)) -}}
{{- with (include "ix.v1.common.util.annotations.render" (dict "root" $ "annotations" $annotations) | trim) }}
annotations:
{{- . | nindent 4 }}