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