From 7f52e732c1d33bf1ad018a4650c3911d32e6df34 Mon Sep 17 00:00:00 2001 From: Kjeld Schouten-Lebbing Date: Fri, 28 May 2021 01:22:40 +0200 Subject: [PATCH] port external Interfaces from iXOfficial (#525) * port external Interfaces from iXOfficial * Fix, Clean and Polish --- charts/library/common/Chart.yaml | 2 +- charts/library/common/templates/_daemonset.tpl | 6 ++++-- charts/library/common/templates/_deployment.tpl | 6 ++++-- charts/library/common/templates/_statefulset.tpl | 6 ++++-- .../templates/classes/_externalInterfaces.tpl | 15 +++++++++++++++ .../common/templates/lib/chart/_annotations.tpl | 11 +++++++++++ 6 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 charts/library/common/templates/classes/_externalInterfaces.tpl create mode 100644 charts/library/common/templates/lib/chart/_annotations.tpl diff --git a/charts/library/common/Chart.yaml b/charts/library/common/Chart.yaml index a272a2307c1..7afd6b130a3 100644 --- a/charts/library/common/Chart.yaml +++ b/charts/library/common/Chart.yaml @@ -19,4 +19,4 @@ name: common sources: - https://github.com/truecharts/apps/tree/master/library/common type: library -version: 5.0.2 +version: 5.1.0 diff --git a/charts/library/common/templates/_daemonset.tpl b/charts/library/common/templates/_daemonset.tpl index 0f0670cf40a..239d9c1742d 100644 --- a/charts/library/common/templates/_daemonset.tpl +++ b/charts/library/common/templates/_daemonset.tpl @@ -13,8 +13,9 @@ metadata: {{- with .Values.controller.labels }} {{- toYaml . | nindent 4 }} {{- end }} - {{- with .Values.controller.annotations }} annotations: + {{- include "common.annotations.workload" . | nindent 4 }} + {{- with .Values.controller.annotations }} {{- toYaml . | nindent 4 }} {{- end }} spec: @@ -24,8 +25,9 @@ spec: {{- include "common.labels.selectorLabels" . | nindent 6 }} template: metadata: - {{- with .Values.podAnnotations }} annotations: + {{- include "common.annotations.workload.spec" . | nindent 8 }} + {{- with .Values.podAnnotations }} {{- toYaml . | nindent 8 }} {{- end }} labels: diff --git a/charts/library/common/templates/_deployment.tpl b/charts/library/common/templates/_deployment.tpl index 4cb645b58cf..9b0cb4158ca 100644 --- a/charts/library/common/templates/_deployment.tpl +++ b/charts/library/common/templates/_deployment.tpl @@ -13,8 +13,9 @@ metadata: {{- with .Values.controller.labels }} {{- toYaml . | nindent 4 }} {{- end }} - {{- with .Values.controller.annotations }} annotations: + {{- include "common.annotations.workload" . | nindent 4 }} + {{- with .Values.controller.annotations }} {{- toYaml . | nindent 4 }} {{- end }} spec: @@ -42,8 +43,9 @@ spec: {{- include "common.labels.selectorLabels" . | nindent 6 }} template: metadata: - {{- with .Values.podAnnotations }} annotations: + {{- include "common.annotations.workload.spec" . | nindent 8 }} + {{- with .Values.podAnnotations }} {{- toYaml . | nindent 8 }} {{- end }} labels: diff --git a/charts/library/common/templates/_statefulset.tpl b/charts/library/common/templates/_statefulset.tpl index 24579fa06af..59f7551a61a 100644 --- a/charts/library/common/templates/_statefulset.tpl +++ b/charts/library/common/templates/_statefulset.tpl @@ -31,8 +31,9 @@ metadata: {{- with .Values.controller.labels }} {{- toYaml . | nindent 4 }} {{- end }} - {{- with .Values.controller.annotations }} annotations: + {{- include "common.annotations.workload" . | nindent 4 }} + {{- with .Values.controller.annotations }} {{- toYaml . | nindent 4 }} {{- end }} spec: @@ -54,8 +55,9 @@ spec: serviceName: {{ include "common.names.fullname" . }} template: metadata: - {{- with .Values.podAnnotations }} annotations: + {{- include "common.annotations.workload.spec" . | nindent 8 }} + {{- with .Values.podAnnotations }} {{- toYaml . | nindent 8 }} {{- end }} labels: diff --git a/charts/library/common/templates/classes/_externalInterfaces.tpl b/charts/library/common/templates/classes/_externalInterfaces.tpl new file mode 100644 index 00000000000..375e3612a0a --- /dev/null +++ b/charts/library/common/templates/classes/_externalInterfaces.tpl @@ -0,0 +1,15 @@ +{{/* +This template serves as a blueprint for External Interface objects that are created +using the SCALE GUI. +*/}} +{{- define "common.classes.externalInterfaces" -}} +{{- range $index, $iface := .Values.externalInterfaces }} +--- +apiVersion: "k8s.cni.cncf.io/v1" +kind: NetworkAttachmentDefinition +metadata: + name: ix-{{ $.Release.Name }}-{{ $index }} +spec: + config: '{{ $iface }}' +{{- end }} +{{- end -}} diff --git a/charts/library/common/templates/lib/chart/_annotations.tpl b/charts/library/common/templates/lib/chart/_annotations.tpl new file mode 100644 index 00000000000..739b6bccd9d --- /dev/null +++ b/charts/library/common/templates/lib/chart/_annotations.tpl @@ -0,0 +1,11 @@ +{{/* Common annotations shared across objects */}} +{{- define "common.annotations.workload.spec" -}} +rollme: {{ randAlphaNum 5 | quote }} +{{- if .Values.externalInterfaces }} +k8s.v1.cni.cncf.io/networks: {{ join ", " .Values.externalInterfaces }} +{{- end }} +{{- end -}} + +{{- define "common.annotations.workload" -}} +rollme: {{ randAlphaNum 5 | quote }} +{{- end -}}