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