Prechádzať zdrojové kódy

Add ability to add external ifaces using macvlan

Waqar Ahmed 4 rokov pred
rodič
commit
08b3e9e5c9

+ 41 - 0
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"

+ 7 - 0
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 }}

+ 8 - 0
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 }}

+ 9 - 0
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 }}

+ 3 - 0
charts/ix-chart/2009.0.1/values.yaml

@@ -10,3 +10,6 @@ image:
 containerCommand: []
 containerArgs: []
 containerEnvironmentVariables: []
+
+# Network related configuration
+externalInterfaces: []