From 08b3e9e5c9bfc107f41ef5b527d2040283453e6e Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Fri, 2 Oct 2020 23:23:20 +0500 Subject: [PATCH] Add ability to add external ifaces using macvlan --- charts/ix-chart/2009.0.1/questions.yaml | 41 +++++++++++++++++++ .../ix-chart/2009.0.1/templates/_helpers.tpl | 7 ++++ .../2009.0.1/templates/deployment.yaml | 8 ++++ .../templates/external-interfaces.yaml.py | 9 ++++ charts/ix-chart/2009.0.1/values.yaml | 3 ++ 5 files changed, 68 insertions(+) create mode 100644 charts/ix-chart/2009.0.1/templates/external-interfaces.yaml.py diff --git a/charts/ix-chart/2009.0.1/questions.yaml b/charts/ix-chart/2009.0.1/questions.yaml index 6a5df8b6bc0..5a0121d70a1 100644 --- a/charts/ix-chart/2009.0.1/questions.yaml +++ b/charts/ix-chart/2009.0.1/questions.yaml @@ -82,3 +82,44 @@ schema: type: string required: true + +# Networking options +- variable: externalInterfaces + description: "Add External Interfaces" + label: "Add external Interfaces" + group: "Networking" + schema: + type: list + items: + - variable: interfaceConfiguration + description: "Interface Configuration" + label: "Interface Configuration" + schema: + type: dict + $ref: + - "normalise/interfaceConfiguration" + attrs: + - variable: hostInterface + description: "Please specify host interface" + label: "Host Interface" + schema: + type: string + required: true + $ref: + - "definitions/interface" + - variable: ipam + description: "Define how IP Address will be managed" + label: "IP Address Management" + schema: + type: dict + required: true + attrs: + - variable: type + description: "Specify type for IPAM" + label: "IPAM Type" + schema: + type: string + required: true + enum: + - "dhcp" + - "static" diff --git a/charts/ix-chart/2009.0.1/templates/_helpers.tpl b/charts/ix-chart/2009.0.1/templates/_helpers.tpl index cc466748a14..2f783e56ae7 100644 --- a/charts/ix-chart/2009.0.1/templates/_helpers.tpl +++ b/charts/ix-chart/2009.0.1/templates/_helpers.tpl @@ -61,3 +61,10 @@ Create the name of the service account to use {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} + +{{/* +Name for external interfaces to be added to chart +*/}} +{{- define "externalInterfaceName" -}} +{{- printf "%s" .Release.Name }} +{{- end }} diff --git a/charts/ix-chart/2009.0.1/templates/deployment.yaml b/charts/ix-chart/2009.0.1/templates/deployment.yaml index c231d2710a2..ec23c8b0f49 100644 --- a/charts/ix-chart/2009.0.1/templates/deployment.yaml +++ b/charts/ix-chart/2009.0.1/templates/deployment.yaml @@ -12,6 +12,14 @@ spec: metadata: labels: {{- include "ix-chart.selectorLabels" . | nindent 8 }} + annotations: + rollme: {{ randAlphaNum 5 | quote }} + {{- if .Values.externalInterfaces }} + k8s.v1.cni.cncf.io/networks: + {{- range $index, $iface := .Values.externalInterfaces }} + - {{ include "externalInterfaceName" . }}-{{ $index }} + {{- end }} + {{- end }} spec: containers: - name: {{ .Chart.Name }} diff --git a/charts/ix-chart/2009.0.1/templates/external-interfaces.yaml.py b/charts/ix-chart/2009.0.1/templates/external-interfaces.yaml.py new file mode 100644 index 00000000000..439f0890981 --- /dev/null +++ b/charts/ix-chart/2009.0.1/templates/external-interfaces.yaml.py @@ -0,0 +1,9 @@ +{{- range $index, $iface := .Values.externalInterfaces }} +apiVersion: "k8s.cni.cncf.io/v1" +kind: NetworkAttachmentDefinition +metadata: + name: {{ include "externalInterfaceName" . }}-{{ $index }} +spec: + config: '{{ $iface }}' +---------------------------------------------------------- +{{- end }} diff --git a/charts/ix-chart/2009.0.1/values.yaml b/charts/ix-chart/2009.0.1/values.yaml index 116b6240317..8baa57459aa 100644 --- a/charts/ix-chart/2009.0.1/values.yaml +++ b/charts/ix-chart/2009.0.1/values.yaml @@ -10,3 +10,6 @@ image: containerCommand: [] containerArgs: [] containerEnvironmentVariables: [] + +# Network related configuration +externalInterfaces: []