Near RT RIC Platform new-installer initial release
[ric-plt/ric-dep.git] / new-installer / helm / charts / nearrtric / 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 {{- $health := .Values.health }}
19 {{- $common_env := .Values.common_env_variables }}
20 {{- range keys .Values.e2term }}
21 {{- $key := . }}
22 {{- with index $topCtx.Values.e2term . }}
23
24 {{- $imagectx := dict "ctx" $topCtx "defaultregistry" .image.registry }}
25 {{- $pullpolicyctx := dict "ctx" $topCtx "defaultpullpolicy" .imagePullPolicy }}
26 ---
27 apiVersion: apps/v1
28 kind: Deployment
29 metadata:
30   name: {{ include "common.deploymentname.e2term" $topCtx }}-{{ $key }}
31   namespace: {{ include "common.namespace.platform" $topCtx }}
32   labels:
33     app: {{ include "common.namespace.platform" $topCtx }}-{{ include "common.name.e2term" $topCtx }}-{{ $key }}
34     chart: {{ $topCtx.Chart.Name }}-{{ $topCtx.Chart.Version | replace "+" "_" }}
35     release: {{ $topCtx.Release.Name }}
36     heritage: {{ $topCtx.Release.Service }}
37 spec:
38   replicas: {{ .replicaCount }}
39   selector:
40     matchLabels:
41       app: {{ include "common.namespace.platform" $topCtx }}-{{ include "common.name.e2term" $topCtx }}-{{ $key }}
42       release: {{ $topCtx.Release.Name }}
43   template:
44     metadata:
45         {{- if $.Values.global }}
46           {{- if $.Values.global.danm_networks }}
47             {{- $networklist := list }}
48             {{- range $network := $.Values.global.danm_networks }}
49               {{- if $network.tenants }}
50                 {{- if $network.tenants.e2term }}
51                   {{- if (hasKey $network.tenants.e2term $key) }}
52                     {{- $networklist = append $networklist $network }}
53                   {{- end }}
54                 {{- end }}
55               {{- end }}
56             {{- end }}
57             {{- if $networklist }}
58       annotations:
59         danm.k8s.io/interfaces: |
60           [
61             {{- range $network := $networklist }}
62               {{- printf "\n            {\"clusterNetwork\": \"%s\"" $network.name }}
63               {{- with index $network.tenants.e2term $key }}
64               {{- if .ip }}
65                 {{- printf ", \"ip\": \"%s\"" .ip }}
66               {{- else }}
67                 {{- printf ", \"ip\": \"dynamic\"" }}
68               {{- end }}
69               {{- if .ip6 }}
70                 {{- printf ", \"ip6\": \"%s\"" .ip6 }}
71               {{- end }}
72               {{- if .proutes }}
73                 {{- printf ", \"proutes\": {" }}
74                 {{- range $subnet, $gw := .proutes }}
75                   {{- if eq $subnet ( first ( keys .proutes ))}}
76                     {{- printf "\"%s\": \"%s\"" $subnet $gw }}
77                   {{- else }}
78                     {{- printf ", \"%s\": \"%s\"" $subnet $gw }}
79                   {{- end }}
80                 {{- end }}
81                 {{- printf "}" }}
82               {{- end }}
83               {{- end }}
84               {{- if ne $network.name (last $networklist).name }}
85               {{- printf "}," }}
86               {{- else }}
87               {{- printf "}" }}
88               {{- end }}
89             {{- end }}
90           ]
91             {{- end }}
92           {{- end }}
93         {{- end }}
94       labels:
95         app: {{ include "common.namespace.platform" $topCtx }}-{{ include "common.name.e2term" $topCtx }}-{{ $key }}
96         release: {{ $topCtx.Release.Name }}
97     spec:
98       hostname: {{ include "common.name.e2term" $topCtx }}-{{ $key }}
99       hostNetwork: {{ .hostnetworkmode }}
100       dnsPolicy: ClusterFirstWithHostNet
101       imagePullSecrets:
102         - name: {{ include "common.dockerregistry.credential" $imagectx }}
103       {{- with .nodeselector }}
104       nodeSelector: {{ toYaml . | trim | nindent 8 -}}
105       {{- end }}
106       containers:
107         - name: {{ include "common.containername.e2term" $topCtx }}
108           image: {{ include "common.dockerregistry.url" $imagectx }}/{{ .image.name }}:{{ .image.tag }}
109           imagePullPolicy: {{ include "common.dockerregistry.pullpolicy" $pullpolicyctx }}
110           volumeMounts:
111           - mountPath: /opt/e2/router.txt
112             name: local-router-file
113             subPath: router.txt
114           - mountPath: /tmp/rmr_verbose
115             name: local-router-file
116             subPath: rmr_verbose
117           - mountPath: {{ $common_env.ConfigMapName }}
118             name: local-loglevel-file
119             subPath: log-level
120 {{ if .pizpub.enabled }}
121           - mountPath: "{{ .env.messagecollectorfile }}"
122             name: vol-shared
123             readOnly: false
124             subPath: "{{ .pizpub.scanDirectory }}"
125 {{ else }}
126           - mountPath: "{{ .env.messagecollectorfile }}"
127             name: vol-shared
128             readOnly: false
129 {{ end }}
130           envFrom:
131             - configMapRef:
132                 name: {{ include "common.configmapname.e2term" $topCtx }}-env-{{ $key }}
133           env:
134             - name: SYSTEM_NAME
135               value: "SEP"
136             - name: CONFIG_MAP_NAME
137               value: "{{ $common_env.ConfigMapName }}"
138             - name: HOST_NAME
139               valueFrom:
140                fieldRef:
141                 fieldPath: spec.nodeName
142             - name: SERVICE_NAME
143               value: "{{ $common_env.ServiceName }}"
144             - name: CONTAINER_NAME
145               value: "{{ include "common.containername.e2term" $topCtx }}"
146             - name: POD_NAME
147               valueFrom:
148                fieldRef:
149                 fieldPath: metadata.name
150           ports:
151             - name: "rmrroute-{{ $key }}"
152               containerPort: {{ include "common.serviceport.e2term.rmr.route" $topCtx }}
153             - name: "rmrdata-{{ $key }}"
154               containerPort: {{ include "common.serviceport.e2term.rmr.data" $topCtx }}
155             - name: "sctp-{{ $key }}"
156               containerPort: 36422
157               protocol: SCTP
158             - name: "prmts-{{ $key }}"
159               containerPort: {{ include "common.serviceport.e2term.prometheus" $topCtx }}
160           stdin: true
161           tty: true
162           securityContext:
163             privileged: {{ .privilegedmode }}
164           {{- if eq $health.liveness.enabled true }}
165           readinessProbe:
166             exec:
167               command: [ "/bin/sh", "-c", "{{ $health.readiness.command }}:{{ include "common.serviceport.e2term.rmr.data" . }}" ]
168             initialDelaySeconds: {{ $health.readiness.initialDelaySeconds }}
169             periodSeconds: {{ $health.readiness.periodSeconds }}
170           {{- end }}
171           {{- if eq $health.liveness.enabled true }}
172           livenessProbe:
173             exec:
174               command: [ "/bin/sh", "-c", "{{ $health.liveness.command }}:{{ include "common.serviceport.e2term.rmr.data" . }}" ]
175             initialDelaySeconds: {{ $health.liveness.initialDelaySeconds }}
176             periodSeconds: {{ $health.liveness.periodSeconds }}
177           {{- end }}
178 {{ if .pizpub.enabled }}
179         - name: {{ include "common.containername.e2term" $topCtx }}-pizpub
180           {{- $pizpubimagectx := dict "ctx" $topCtx "defaultregistry" .pizpub.image.registry }}
181           image: {{ include "common.dockerregistry.url" $pizpubimagectx }}/{{ .pizpub.image.name }}:{{ .pizpub.image.tag }}
182           imagePullPolicy: {{ include "common.dockerregistry.pullpolicy" $pullpolicyctx }}
183           volumeMounts:
184           - mountPath: /etc/localtime
185             name: localtime
186             readOnly: true
187           - mountPath: "{{ .pizpub.dataRootDir }}"
188             name: vol-shared
189             readOnly: false
190           - name: pizpub-config
191             mountPath: /opt/app/config/conf/
192           lifecycle:
193             postStart:
194               exec:
195                 command: ["/bin/sh", "/opt/app/config/conf/cleaner.sh", "{{ .pizpub.dataRootDir }}/{{ .pizpub.processedDirectory }}", "3"]
196 {{ end }}
197       volumes:
198         - name: local-router-file
199           configMap:
200             name: {{ include "common.configmapname.e2term" $topCtx }}-router-configmap
201         - name: local-loglevel-file
202           configMap:
203             name: {{ include "common.configmapname.e2term" $topCtx }}-loglevel-configmap
204 {{ if .pizpub.enabled }}
205         - name: localtime
206           hostPath:
207             path: /etc/localtime
208         - name: pizpub-config
209           configMap:
210             name: {{ include "common.configmapname.e2term" $topCtx }}-pizpub-{{ $key }}
211 {{ end }}
212         - name: vol-shared
213           persistentVolumeClaim:
214             claimName: {{ include "common.pvcname.e2term" $topCtx }}-{{ $key }}
215
216 {{- end }}
217 {{- end }}