331c156c6c595d30b9607445d98cb9dc6ab595be
[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 .annotations }}
44       annotations:
45         {{- .annotations | nindent 8 -}}
46       {{ end }}
47       labels:
48         app: {{ include "common.namespace.platform" $topCtx }}-{{ include "common.name.e2term" $topCtx }}
49         release: {{ $topCtx.Release.Name }}
50     spec:
51       hostname: {{ include "common.name.e2term" $topCtx }}-{{ $key }}
52       hostNetwork: {{ .hostnetworkmode }}
53       dnsPolicy: ClusterFirstWithHostNet
54       imagePullSecrets:
55         - name: {{ include "common.dockerregistry.credential" $imagectx }}
56       {{- with .nodeselector }}
57       nodeSelector: {{ toYaml . | trim | nindent 8 -}}
58       {{- end }}
59       containers:
60         - name: {{ include "common.containername.e2term" $topCtx }}
61           image: {{ include "common.dockerregistry.url" $imagectx }}/{{ .image.name }}:{{ .image.tag }}
62           imagePullPolicy: {{ include "common.dockerregistry.pullpolicy" $pullpolicyctx }}
63           volumeMounts:
64           - mountPath: /opt/e2/router.txt
65             name: local-router-file
66             subPath: router.txt
67           - mountPath: /tmp/rmr_verbose
68             name: local-router-file
69             subPath: rmr_verbose
70 {{ if .pizpub.enabled }}
71           - mountPath: "{{ .env.messagecollectorfile }}"
72             name: vol-shared
73             readOnly: false
74             subPath: "{{ .pizpub.scanDirectory }}"
75 {{ else }}
76           - mountPath: "{{ .env.messagecollectorfile }}"
77             name: vol-shared
78             readOnly: false
79 {{ end }}
80           envFrom:
81             - configMapRef:
82                 name: {{ include "common.configmapname.e2term" $topCtx }}-env-{{ $key }}
83           ports:
84             - name: "rmrroute-{{ $key }}"
85               containerPort: {{ include "common.serviceport.e2term.rmr.route" $topCtx }}
86             - name: "rmrdata-{{ $key }}"
87               containerPort: {{ include "common.serviceport.e2term.rmr.data" $topCtx }}
88           stdin: true
89           tty: true
90           securityContext:
91             privileged: {{ .privilegedmode }}
92
93 {{ if .pizpub.enabled }}
94         - name: {{ include "common.containername.e2term" $topCtx }}-pizpub
95           {{- $pizpubimagectx := dict "ctx" $topCtx "defaultregistry" .pizpub.image.registry }}
96           image: {{ include "common.dockerregistry.url" $pizpubimagectx }}/{{ .pizpub.image.name }}:{{ .pizpub.image.tag }}
97           imagePullPolicy: {{ include "common.dockerregistry.pullpolicy" $pullpolicyctx }}
98           volumeMounts:
99           - mountPath: /etc/localtime
100             name: localtime
101             readOnly: true
102           - mountPath: "{{ .pizpub.dataRootDir }}"
103             name: vol-shared
104             readOnly: false
105           - name: pizpub-config
106             mountPath: /opt/app/config/conf/
107           lifecycle:
108             postStart:
109               exec:
110                 command: ["/bin/sh", "/opt/app/config/conf/cleaner.sh", "{{ .pizpub.dataRootDir }}/{{ .pizpub.processedDirectory }}", "3"]
111 {{ end }}
112       volumes:
113         - name: local-router-file
114           configMap:
115             name: {{ include "common.configmapname.e2term" $topCtx }}-router-configmap
116 {{ if .pizpub.enabled }}
117         - name: localtime
118           hostPath:
119             path: /etc/localtime
120         - name: pizpub-config
121           configMap:
122             name: {{ include "common.configmapname.e2term" $topCtx }}-pizpub-{{ $key }}
123 {{ end }}
124         - name: vol-shared
125           persistentVolumeClaim:
126             claimName: {{ include "common.pvcname.e2term" $topCtx }}-{{ $key }}
127
128 {{- end }}
129 {{- end }}