Fix E2T dynamic loglevel definitions
[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 {{- $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: {{ dir $common_env.ConfigMapName }}
118             name: local-loglevel-file
119 {{ if .pizpub.enabled }}
120           - mountPath: "{{ .env.messagecollectorfile }}"
121             name: vol-shared
122             readOnly: false
123             subPath: "{{ .pizpub.scanDirectory }}"
124 {{ else }}
125           - mountPath: "{{ .env.messagecollectorfile }}"
126             name: vol-shared
127             readOnly: false
128 {{ end }}
129           envFrom:
130             - configMapRef:
131                 name: {{ include "common.configmapname.e2term" $topCtx }}-env-{{ $key }}
132           env:
133             - name: SYSTEM_NAME
134               value: "SEP"
135             - name: CONFIG_MAP_NAME
136               value: "{{ $common_env.ConfigMapName }}"
137             - name: HOST_NAME
138               valueFrom:
139                fieldRef:
140                 fieldPath: spec.nodeName
141             - name: SERVICE_NAME
142               value: "{{ $common_env.ServiceName }}"
143             - name: CONTAINER_NAME
144               value: "{{ include "common.containername.e2term" $topCtx }}"
145             - name: POD_NAME
146               valueFrom:
147                fieldRef:
148                 fieldPath: metadata.name
149           ports:
150             - name: "rmrroute-{{ $key }}"
151               containerPort: {{ include "common.serviceport.e2term.rmr.route" $topCtx }}
152             - name: "rmrdata-{{ $key }}"
153               containerPort: {{ include "common.serviceport.e2term.rmr.data" $topCtx }}
154             - name: "sctp-{{ $key }}"
155               containerPort: 36422
156               protocol: SCTP
157             - name: "prmts-{{ $key }}"
158               containerPort: {{ include "common.serviceport.e2term.prometheus" $topCtx }}
159           stdin: true
160           tty: true
161           securityContext:
162             privileged: {{ .privilegedmode }}
163           {{- if eq $health.liveness.enabled true }}
164           readinessProbe:
165             exec:
166               command: [ "/bin/sh", "-c", "{{ $health.readiness.command }}:{{ include "common.serviceport.e2term.rmr.data" . }}" ]
167             initialDelaySeconds: {{ $health.readiness.initialDelaySeconds }}
168             periodSeconds: {{ $health.readiness.periodSeconds }}
169           {{- end }}
170           {{- if eq $health.liveness.enabled true }}
171           livenessProbe:
172             exec:
173               command: [ "/bin/sh", "-c", "{{ $health.liveness.command }}:{{ include "common.serviceport.e2term.rmr.data" . }}" ]
174             initialDelaySeconds: {{ $health.liveness.initialDelaySeconds }}
175             periodSeconds: {{ $health.liveness.periodSeconds }}
176           {{- end }}
177 {{ if .pizpub.enabled }}
178         - name: {{ include "common.containername.e2term" $topCtx }}-pizpub
179           {{- $pizpubimagectx := dict "ctx" $topCtx "defaultregistry" .pizpub.image.registry }}
180           image: {{ include "common.dockerregistry.url" $pizpubimagectx }}/{{ .pizpub.image.name }}:{{ .pizpub.image.tag }}
181           imagePullPolicy: {{ include "common.dockerregistry.pullpolicy" $pullpolicyctx }}
182           volumeMounts:
183           - mountPath: /etc/localtime
184             name: localtime
185             readOnly: true
186           - mountPath: "{{ .pizpub.dataRootDir }}"
187             name: vol-shared
188             readOnly: false
189           - name: pizpub-config
190             mountPath: /opt/app/config/conf/
191           lifecycle:
192             postStart:
193               exec:
194                 command: ["/bin/sh", "/opt/app/config/conf/cleaner.sh", "{{ .pizpub.dataRootDir }}/{{ .pizpub.processedDirectory }}", "3"]
195 {{ end }}
196       volumes:
197         - name: local-router-file
198           configMap:
199             name: {{ include "common.configmapname.e2term" $topCtx }}-router-configmap
200         - name: local-loglevel-file
201           configMap:
202             name: {{ include "common.configmapname.e2term" $topCtx }}-loglevel-configmap
203 {{ if .pizpub.enabled }}
204         - name: localtime
205           hostPath:
206             path: /etc/localtime
207         - name: pizpub-config
208           configMap:
209             name: {{ include "common.configmapname.e2term" $topCtx }}-pizpub-{{ $key }}
210 {{ end }}
211         - name: vol-shared
212           persistentVolumeClaim:
213             claimName: {{ include "common.pvcname.e2term" $topCtx }}-{{ $key }}
214
215 {{- end }}
216 {{- end }}