From 6c4afc33f5dc9cd95fe2129fc264af66bc219cb1 Mon Sep 17 00:00:00 2001 From: Zhe Huang Date: Mon, 20 Apr 2020 17:32:39 -0400 Subject: [PATCH] Add DANM network support 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 Change-Id: I0a8ab930e0790afe8226683cd932d3bf90a0ccf5 --- helm/e2term/templates/deployment.yaml | 51 ++++++++++++++++++-- helm/infrastructure/requirements.yaml | 4 ++ .../subcharts/danm-networks/Chart.yaml | 23 +++++++++ .../subcharts/danm-networks/templates/danm.yaml | 55 ++++++++++++++++++++++ .../subcharts/danm-networks/values.yaml | 14 ++++++ .../subcharts/kong/templates/deployment.yaml | 44 +++++++++++++++++ helm/infrastructure/values.yaml | 6 ++- 7 files changed, 193 insertions(+), 4 deletions(-) create mode 100644 helm/infrastructure/subcharts/danm-networks/Chart.yaml create mode 100644 helm/infrastructure/subcharts/danm-networks/templates/danm.yaml create mode 100644 helm/infrastructure/subcharts/danm-networks/values.yaml diff --git a/helm/e2term/templates/deployment.yaml b/helm/e2term/templates/deployment.yaml index 615347e..a58fc1b 100644 --- a/helm/e2term/templates/deployment.yaml +++ b/helm/e2term/templates/deployment.yaml @@ -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 }} diff --git a/helm/infrastructure/requirements.yaml b/helm/infrastructure/requirements.yaml index 2e0bb7b..b1ab3ea 100644 --- a/helm/infrastructure/requirements.yaml +++ b/helm/infrastructure/requirements.yaml @@ -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 index 0000000..0a59405 --- /dev/null +++ b/helm/infrastructure/subcharts/danm-networks/Chart.yaml @@ -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 index 0000000..d52823e --- /dev/null +++ b/helm/infrastructure/subcharts/danm-networks/templates/danm.yaml @@ -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 index 0000000..9d5a116 --- /dev/null +++ b/helm/infrastructure/subcharts/danm-networks/values.yaml @@ -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. # +################################################################################ diff --git a/helm/infrastructure/subcharts/kong/templates/deployment.yaml b/helm/infrastructure/subcharts/kong/templates/deployment.yaml index de07aa7..40afe66 100755 --- a/helm/infrastructure/subcharts/kong/templates/deployment.yaml +++ b/helm/infrastructure/subcharts/kong/templates/deployment.yaml @@ -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 diff --git a/helm/infrastructure/values.yaml b/helm/infrastructure/values.yaml index 537a005..bd0c0f5 100644 --- a/helm/infrastructure/values.yaml +++ b/helm/infrastructure/values.yaml @@ -74,7 +74,11 @@ docker-credential: certificate-manager: enabled: true - + + +danm-network: + enabled: true + kong: enabled: true -- 2.16.6