Add DANM network support 66/3366/4
authorZhe Huang <zhehuang@research.att.com>
Mon, 20 Apr 2020 21:32:39 +0000 (17:32 -0400)
committerZhe Huang <zhehuang@research.att.com>
Tue, 28 Apr 2020 02:08:39 +0000 (22:08 -0400)
This commit allows us to add DANM network definitions in the recipe.
Corresponding RIC component helm charts that support DANM networks will
automatically pick up the network configuration.

Signed-off-by: Zhe Huang <zhehuang@research.att.com>
Change-Id: I0a8ab930e0790afe8226683cd932d3bf90a0ccf5

helm/e2term/templates/deployment.yaml
helm/infrastructure/requirements.yaml
helm/infrastructure/subcharts/danm-networks/Chart.yaml [new file with mode: 0644]
helm/infrastructure/subcharts/danm-networks/templates/danm.yaml [new file with mode: 0644]
helm/infrastructure/subcharts/danm-networks/values.yaml [new file with mode: 0644]
helm/infrastructure/subcharts/kong/templates/deployment.yaml
helm/infrastructure/values.yaml

index 615347e..a58fc1b 100644 (file)
@@ -40,10 +40,55 @@ spec:
       release: {{ $topCtx.Release.Name }}
   template:
     metadata:
-      {{- if .annotations }}
+        {{- if $.Values.global }}
+          {{- if $.Values.global.danm_networks }}
+            {{- $networklist := list }}
+            {{- range $network := $.Values.global.danm_networks }}
+              {{- if $network.tenants }}
+                {{- if $network.tenants.e2term }}
+                  {{- if (hasKey $network.tenants.e2term $key) }}
+                    {{- $networklist = append $networklist $network }}
+                  {{- end }}
+                {{- end }}
+              {{- end }}
+            {{- end }}
+            {{- if $networklist }}
       annotations:
-        {{- .annotations | nindent 8 -}}
-      {{ end }}
+        danm.k8s.io/interfaces: |
+          [
+            {{- range $network := $networklist }}
+              {{- printf "\n            {\"clusterNetwork\": \"%s\"" $network.name }}
+              {{- with index $network.tenants.e2term $key }}
+              {{- if .ip }}
+                {{- printf ", \"ip\": \"%s\"" .ip }}
+              {{- else }}
+                {{- printf ", \"ip\": \"dynamic\"" }}
+              {{- end }}
+              {{- if .ip6 }}
+                {{- printf ", \"ip6\": \"%s\"" .ip6 }}
+              {{- end }}
+              {{- if .proutes }}
+                {{- printf ", \"proutes\": {" }}
+                {{- range $subnet, $gw := .proutes }}
+                  {{- if eq $subnet ( first ( keys .proutes ))}}
+                    {{- printf "\"%s\": \"%s\"" $subnet $gw }}
+                  {{- else }}
+                    {{- printf ", \"%s\": \"%s\"" $subnet $gw }}
+                  {{- end }}
+                {{- end }}
+                {{- printf "}" }}
+              {{- end }}
+              {{- end }}
+              {{- if ne $network.name (last $networklist).name }}
+              {{- printf "}," }}
+              {{- else }}
+              {{- printf "}" }}
+              {{- end }}
+            {{- end }}
+          ]
+            {{- end }}
+          {{- end }}
+        {{- end }}
       labels:
         app: {{ include "common.namespace.platform" $topCtx }}-{{ include "common.name.e2term" $topCtx }}
         release: {{ $topCtx.Release.Name }}
index 2e0bb7b..b1ab3ea 100644 (file)
@@ -35,3 +35,7 @@ dependencies:
     version: 0.1.0
     repository: "file://./subcharts/certificate-manager"
     condition: certificate-manager.enabled
+  - name: danm-networks
+    version: 1.0.0
+    repository: "file://./subcharts/danm-networks"
+    condition: danm-networks.enabled
diff --git a/helm/infrastructure/subcharts/danm-networks/Chart.yaml b/helm/infrastructure/subcharts/danm-networks/Chart.yaml
new file mode 100644 (file)
index 0000000..0a59405
--- /dev/null
@@ -0,0 +1,23 @@
+################################################################################
+#   Copyright (c) 2019 AT&T Intellectual Property.                             #
+#   Copyright (c) 2019 Nokia.                                                  #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+
+apiVersion: v1
+appVersion: "1.0"
+description: A Helm chart for setting up danm networks
+name: danm-networks
+version: 1.0.0
+
diff --git a/helm/infrastructure/subcharts/danm-networks/templates/danm.yaml b/helm/infrastructure/subcharts/danm-networks/templates/danm.yaml
new file mode 100644 (file)
index 0000000..d52823e
--- /dev/null
@@ -0,0 +1,55 @@
+#   Copyright (c) 2019 AT&T Intellectual Property.                             #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+{{- if $.Values.global }}
+{{- if $.Values.global.danm_networks }}
+{{- range keys $.Values.global.danm_networks }}
+{{- with index $.Values.global.danm_networks . }}
+{{- if ne .name "default" }}
+---
+apiVersion: danm.k8s.io/v1
+kind: ClusterNetwork
+metadata:
+  name: {{.name}}
+spec:
+  NetworkID: {{.network_id}}
+  NetworkType: {{.network_type}}
+  Options:
+    cidr: {{.cidr}}
+    allocation_pool:
+      start: {{.allocation_pool.start}}
+      end: {{.allocation_pool.end}}
+{{- if .routes }}
+    routes:
+{{- range $subnet, $route := .routes }}
+      {{ $subnet | quote }}: {{ $route | quote }}
+{{- end }}
+{{- end }}
+{{- if .net6 }}
+    net6: {{ .net6 }}
+{{- end }}
+{{- if .routes }}
+    routes6:
+{{- range $subnet, $route := .routes6 }}
+      {{ $subnet | quote }}: {{ $route | quote }}
+{{- end }}
+{{- end }}
+    host_device: {{ .host_device }}
+    rt_tables: {{ .rt_tables }}
+    vlan: {{ .vlan }}
+{{- end }}
+{{- end }}
+{{- end }}
+{{- end }}
+{{- end }}
diff --git a/helm/infrastructure/subcharts/danm-networks/values.yaml b/helm/infrastructure/subcharts/danm-networks/values.yaml
new file mode 100644 (file)
index 0000000..9d5a116
--- /dev/null
@@ -0,0 +1,14 @@
+#   Copyright (c) 2019 AT&T Intellectual Property.                             #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
index de07aa7..40afe66 100755 (executable)
@@ -29,6 +29,50 @@ spec:
         {{- if .Values.podAnnotations }}
 {{ toYaml .Values.podAnnotations | indent 8 }}
         {{- end }}
+        {{- if $.Values.global }}
+          {{- if $.Values.global.danm_networks }}
+            {{- $networklist := list }}
+            {{- range $network := $.Values.global.danm_networks }}
+              {{- if $network.tenants }}
+                {{- if $network.tenants.kong }}
+                  {{- $networklist = append $networklist $network }}
+                {{- end }}
+              {{- end }}
+            {{- end }}
+            {{- if $networklist }}
+        danm.k8s.io/interfaces: |
+          [
+            {{- range $network := $networklist }}
+              {{- printf "\n            {\"clusterNetwork\": \"%s\"" $network.name }}
+              {{- if $network.tenants.kong.ip }}
+                {{- printf ", \"ip\": \"%s\"" $network.tenants.kong.ip }}
+              {{- else }}
+                {{- printf ", \"ip\": \"dynamic\"" }}
+              {{- end }}
+              {{- if $network.tenants.kong.ip6 }}
+                {{- printf ", \"ip6\": \"%s\"" $network.tenants.kong.ip6 }}
+              {{- end }}
+              {{- if $network.tenants.kong.proutes }}
+                {{- printf ", \"proutes\": {" }}
+                {{- range $subnet, $gw := $network.tenants.kong.proutes }}
+                  {{- if eq $subnet ( first ( keys $network.tenants.kong.proutes ))}}
+                    {{- printf "\"%s\": \"%s\"" $subnet $gw }}
+                  {{- else }}
+                    {{- printf ", \"%s\": \"%s\"" $subnet $gw }}
+                  {{- end }}
+                {{- end }}
+                {{- printf "}" }}
+              {{- end }}
+              {{- if ne $network.name (last $networklist).name }}
+              {{- printf "}," }}
+              {{- else }}
+              {{- printf "}" }}
+              {{- end }}
+            {{- end }}
+          ] 
+            {{- end }}
+          {{- end }}
+        {{- end }}
       labels:
         {{- include "kong.metaLabels" . | nindent 8 }}
         app.kubernetes.io/component: app
index 537a005..bd0c0f5 100644 (file)
@@ -74,7 +74,11 @@ docker-credential:
 
 certificate-manager:
   enabled: true
-      
+
+
+danm-network:
+  enabled: true
+
 
 kong:
   enabled: true