a58fc1b74aea95aa0e805c0b7cce37165ea30432
[ric-plt/ric-dep.git] / helm / e2term / templates / deployment.yaml
1 ################################################################################
2 #   Copyright (c) 2019 AT&T Intellectual Property.                             #
3 #   Copyright (c) 2019 Nokia.                                                  #
4 #                                                                              #
5 #   Licensed under the Apache License, Version 2.0 (the "License");            #
6 #   you may not use this file except in compliance with the License.           #
7 #   You may obtain a copy of the License at                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
11 #   Unless required by applicable law or agreed to in writing, software        #
12 #   distributed under the License is distributed on an "AS IS" BASIS,          #
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
14 #   See the License for the specific language governing permissions and        #
15 #   limitations under the License.                                             #
16 ################################################################################
17 {{- $topCtx :=  . }}
18 {{- range keys .Values.e2term }}
19 {{- $key := . }}
20 {{- with index $topCtx.Values.e2term . }}
21
22 {{- $imagectx := dict "ctx" $topCtx "defaultregistry" .image.registry }}
23 {{- $pullpolicyctx := dict "ctx" $topCtx "defaultpullpolicy" .imagePullPolicy }}
24 ---
25 apiVersion: apps/v1
26 kind: Deployment
27 metadata:
28   name: {{ include "common.deploymentname.e2term" $topCtx }}-{{ $key }}
29   namespace: {{ include "common.namespace.platform" $topCtx }}
30   labels:
31     app: {{ include "common.namespace.platform" $topCtx }}-{{ include "common.name.e2term" $topCtx }}
32     chart: {{ $topCtx.Chart.Name }}-{{ $topCtx.Chart.Version | replace "+" "_" }}
33     release: {{ $topCtx.Release.Name }}
34     heritage: {{ $topCtx.Release.Service }}
35 spec:
36   replicas: {{ .replicaCount }}
37   selector:
38     matchLabels:
39       app: {{ include "common.namespace.platform" $topCtx }}-{{ include "common.name.e2term" $topCtx }}
40       release: {{ $topCtx.Release.Name }}
41   template:
42     metadata:
43         {{- if $.Values.global }}
44           {{- if $.Values.global.danm_networks }}
45             {{- $networklist := list }}
46             {{- range $network := $.Values.global.danm_networks }}
47               {{- if $network.tenants }}
48                 {{- if $network.tenants.e2term }}
49                   {{- if (hasKey $network.tenants.e2term $key) }}
50                     {{- $networklist = append $networklist $network }}
51                   {{- end }}
52                 {{- end }}
53               {{- end }}
54             {{- end }}
55             {{- if $networklist }}
56       annotations:
57         danm.k8s.io/interfaces: |
58           [
59             {{- range $network := $networklist }}
60               {{- printf "\n            {\"clusterNetwork\": \"%s\"" $network.name }}
61               {{- with index $network.tenants.e2term $key }}
62               {{- if .ip }}
63                 {{- printf ", \"ip\": \"%s\"" .ip }}
64               {{- else }}
65                 {{- printf ", \"ip\": \"dynamic\"" }}
66               {{- end }}
67               {{- if .ip6 }}
68                 {{- printf ", \"ip6\": \"%s\"" .ip6 }}
69               {{- end }}
70               {{- if .proutes }}
71                 {{- printf ", \"proutes\": {" }}
72                 {{- range $subnet, $gw := .proutes }}
73                   {{- if eq $subnet ( first ( keys .proutes ))}}
74                     {{- printf "\"%s\": \"%s\"" $subnet $gw }}
75                   {{- else }}
76                     {{- printf ", \"%s\": \"%s\"" $subnet $gw }}
77                   {{- end }}
78                 {{- end }}
79                 {{- printf "}" }}
80               {{- end }}
81               {{- end }}
82               {{- if ne $network.name (last $networklist).name }}
83               {{- printf "}," }}
84               {{- else }}
85               {{- printf "}" }}
86               {{- end }}
87             {{- end }}
88           ]
89             {{- end }}
90           {{- end }}
91         {{- end }}
92       labels:
93         app: {{ include "common.namespace.platform" $topCtx }}-{{ include "common.name.e2term" $topCtx }}
94         release: {{ $topCtx.Release.Name }}
95     spec:
96       hostname: {{ include "common.name.e2term" $topCtx }}-{{ $key }}
97       hostNetwork: {{ .hostnetworkmode }}
98       dnsPolicy: ClusterFirstWithHostNet
99       imagePullSecrets:
100         - name: {{ include "common.dockerregistry.credential" $imagectx }}
101       {{- with .nodeselector }}
102       nodeSelector: {{ toYaml . | trim | nindent 8 -}}
103       {{- end }}
104       containers:
105         - name: {{ include "common.containername.e2term" $topCtx }}
106           image: {{ include "common.dockerregistry.url" $imagectx }}/{{ .image.name }}:{{ .image.tag }}
107           imagePullPolicy: {{ include "common.dockerregistry.pullpolicy" $pullpolicyctx }}
108           volumeMounts:
109           - mountPath: /opt/e2/router.txt
110             name: local-router-file
111             subPath: router.txt
112           - mountPath: /tmp/rmr_verbose
113             name: local-router-file
114             subPath: rmr_verbose
115 {{ if .pizpub.enabled }}
116           - mountPath: "{{ .env.messagecollectorfile }}"
117             name: vol-shared
118             readOnly: false
119             subPath: "{{ .pizpub.scanDirectory }}"
120 {{ else }}
121           - mountPath: "{{ .env.messagecollectorfile }}"
122             name: vol-shared
123             readOnly: false
124 {{ end }}
125           envFrom:
126             - configMapRef:
127                 name: {{ include "common.configmapname.e2term" $topCtx }}-env-{{ $key }}
128           ports:
129             - name: "rmrroute-{{ $key }}"
130               containerPort: {{ include "common.serviceport.e2term.rmr.route" $topCtx }}
131             - name: "rmrdata-{{ $key }}"
132               containerPort: {{ include "common.serviceport.e2term.rmr.data" $topCtx }}
133             - name: "rmrsctp-{{ $key }}" 
134               containerPort: 36422
135               protocol: SCTP 
136           stdin: true
137           tty: true
138           securityContext:
139             privileged: {{ .privilegedmode }}
140
141 {{ if .pizpub.enabled }}
142         - name: {{ include "common.containername.e2term" $topCtx }}-pizpub
143           {{- $pizpubimagectx := dict "ctx" $topCtx "defaultregistry" .pizpub.image.registry }}
144           image: {{ include "common.dockerregistry.url" $pizpubimagectx }}/{{ .pizpub.image.name }}:{{ .pizpub.image.tag }}
145           imagePullPolicy: {{ include "common.dockerregistry.pullpolicy" $pullpolicyctx }}
146           volumeMounts:
147           - mountPath: /etc/localtime
148             name: localtime
149             readOnly: true
150           - mountPath: "{{ .pizpub.dataRootDir }}"
151             name: vol-shared
152             readOnly: false
153           - name: pizpub-config
154             mountPath: /opt/app/config/conf/
155           lifecycle:
156             postStart:
157               exec:
158                 command: ["/bin/sh", "/opt/app/config/conf/cleaner.sh", "{{ .pizpub.dataRootDir }}/{{ .pizpub.processedDirectory }}", "3"]
159 {{ end }}
160       volumes:
161         - name: local-router-file
162           configMap:
163             name: {{ include "common.configmapname.e2term" $topCtx }}-router-configmap
164 {{ if .pizpub.enabled }}
165         - name: localtime
166           hostPath:
167             path: /etc/localtime
168         - name: pizpub-config
169           configMap:
170             name: {{ include "common.configmapname.e2term" $topCtx }}-pizpub-{{ $key }}
171 {{ end }}
172         - name: vol-shared
173           persistentVolumeClaim:
174             claimName: {{ include "common.pvcname.e2term" $topCtx }}-{{ $key }}
175
176 {{- end }}
177 {{- end }}