[DCAEMOD] Uses new tpls for repos / images
[oom.git] / kubernetes / sdc / components / sdc-onboarding-be / templates / deployment.yaml
1 {{/*
2 # Copyright © 2017 Amdocs, AT&T, Bell Canada
3 # Modifications Copyright © 2018  ZTE
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
18 apiVersion: apps/v1
19 kind: Deployment
20 metadata:
21   name: {{ include "common.fullname" . }}
22   namespace: {{ include "common.namespace" . }}
23   labels:
24     app: {{ include "common.name" . }}
25     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
26     release: {{ include "common.release" . }}
27     heritage: {{ .Release.Service }}
28 spec:
29   selector:
30     matchLabels:
31       app: {{ include "common.name" . }}
32   replicas: {{ .Values.replicaCount }}
33   template:
34     metadata:
35       labels:
36         app: {{ include "common.name" . }}
37         release: {{ include "common.release" . }}
38     spec:
39       initContainers: {{ include "common.certInitializer.initContainer" . | nindent 6 }}
40       - name: {{ include "common.name" . }}-job-completion
41         image: "{{ include "common.repository" . }}/{{ .Values.global.readinessImage }}"
42         imagePullPolicy: "{{ .Values.global.pullPolicy | default .Values.pullPolicy }}"
43         command:
44         - /app/ready.py
45         args:
46         - --job-name
47         - {{ include "common.release" . }}-sdc-onboarding-be-cassandra-init
48         env:
49         - name: NAMESPACE
50           valueFrom:
51             fieldRef:
52               apiVersion: v1
53               fieldPath: metadata.namespace
54         resources:
55           limits:
56             cpu: 100m
57             memory: 100Mi
58           requests:
59             cpu: 3m
60             memory: 20Mi
61       {{- if .Values.global.aafEnabled }}
62       - name: {{ include "common.name" . }}-update-config
63         image: "{{ .Values.global.envsubstImage }}"
64         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
65         command:
66         - sh
67         args:
68         - "-c"
69         - |
70           export $(grep '^c' {{ .Values.certInitializer.credsPath }}/mycreds.prop | xargs -0)
71           export KEYSTORE_PASS=$cadi_keystore_password_p12
72           export KEYMANAGER_PASS=$cadi_keystore_password_p12
73           export TRUSTSTORE_PASS=$cadi_truststore_password
74           cp {{ .Values.certInitializer.credsPath }}/{{ .Values.certInitializer.keystoreFile }} /config-output
75           cp {{ .Values.certInitializer.credsPath }}/{{ .Values.certInitializer.truststoreFile }} /config-output
76           cd /config-input && \
77           for PFILE in `find . -not -type d | grep -v -F ..`
78           do
79             envsubst <${PFILE} >/config-output/${PFILE}
80             chmod 0755 /config-output/${PFILE}
81           done
82         volumeMounts: {{ include "common.certInitializer.volumeMount" . | nindent 10 }}
83           - name: {{ include "common.fullname" . }}-environments
84             mountPath: /config-input/
85           - name: sdc-environments-output
86             mountPath: /config-output/
87         resources:
88           limits:
89             cpu: 100m
90             memory: 100Mi
91           requests:
92             cpu: 3m
93             memory: 20Mi
94       {{- end }}
95       containers:
96         - name: {{ include "common.name" . }}
97           image: "{{ include "common.repository" . }}/{{ .Values.image }}"
98           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
99           ports:
100           - containerPort: {{ .Values.service.internalPort }}
101           - containerPort: {{ .Values.service.internalPort2 }}
102           {{ if eq .Values.liveness.enabled true }}
103           livenessProbe:
104             exec:
105               command:
106               - "/var/lib/jetty/ready-probe.sh"
107             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
108             periodSeconds: {{ .Values.liveness.periodSeconds }}
109             timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
110           {{ end }}
111           readinessProbe:
112             exec:
113               command:
114               - "/var/lib/jetty/ready-probe.sh"
115             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
116             periodSeconds: {{ .Values.readiness.periodSeconds }}
117             timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
118           resources: {{ include "common.resources" . | nindent 12 }}
119           env:
120           - name: ENVNAME
121             value: {{ .Values.env.name }}
122           - name: JAVA_OPTIONS
123             value: {{ .Values.config.javaOptions }}
124           - name: SDC_CLUSTER_NAME
125             value: "SDC-CS-{{ .Values.env.name }}"
126           - name: cassandra_ssl_enabled
127             value: {{ .Values.config.cassandraSslEnabled | quote }}
128           - name: HOST_IP
129             valueFrom:
130               fieldRef:
131                 fieldPath: status.podIP
132           - name: SDC_USER
133             valueFrom:
134               secretKeyRef: {name: {{ include "common.release" . }}-sdc-cs-secrets, key: sdc_user}
135           - name: SDC_PASSWORD
136             valueFrom:
137               secretKeyRef: {name: {{ include "common.release" . }}-sdc-cs-secrets, key: sdc_password}
138           - name: SDC_CERT_DIR
139             value: {{ .Values.cert.certDir }}
140           volumeMounts:
141           - name: sdc-environments-output
142             mountPath: /var/lib/jetty/chef-solo/environments/
143           - name: sdc-environments-output
144             mountPath: /var/lib/jetty/chef-solo/cookbooks/sdc-onboard-backend/files/default/org.onap.sdc.p12
145             subPath: org.onap.sdc.p12
146           - name: sdc-environments-output
147             mountPath: /var/lib/jetty/chef-solo/cookbooks/sdc-onboard-backend/files/default/org.onap.sdc.trust.jks
148             subPath: org.onap.sdc.trust.jks
149           - name: {{ include "common.fullname" . }}-localtime
150             mountPath: /etc/localtime
151             readOnly: true
152           - name: {{ include "common.fullname" . }}-logs
153             mountPath: /var/log/onap
154           - name: {{ include "common.fullname" . }}-cert-storage
155             mountPath: "{{ .Values.cert.certDir }}"
156           - name: {{ include "common.fullname" . }}-logback
157             mountPath: /tmp/logback.xml
158             subPath: logback.xml
159           lifecycle:
160             postStart:
161               exec:
162                 command: ["/bin/sh", "-c", "export LOG=wait_logback.log; touch $LOG; export SRC=/tmp/logback.xml; export DST=/var/lib/jetty/config/onboarding-be/; while [ ! -e $DST ]; do echo 'Waiting for $DST...' >> $LOG; sleep 5; done; sleep 2; /bin/cp -f $SRC $DST; echo 'Done' >> $LOG"]
163         # side car containers
164         - name: {{ include "common.name" . }}-filebeat-onap
165           image: "{{ .Values.global.loggingRepository }}/{{ .Values.global.loggingImage }}"
166           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
167           volumeMounts:
168           - name: {{ include "common.fullname" . }}-filebeat-conf
169             mountPath: /usr/share/filebeat/filebeat.yml
170             subPath: filebeat.yml
171           - name: {{ include "common.fullname" . }}-logs
172             mountPath: /var/log/onap
173           - name: {{ include "common.fullname" . }}-data-filebeat
174             mountPath: /usr/share/filebeat/data
175           resources:
176             limits:
177               cpu: 100m
178               memory: 100Mi
179             requests:
180               cpu: 3m
181               memory: 20Mi
182       volumes: {{ include "common.certInitializer.volumes" . | nindent 6 }}
183       - name: {{ include "common.fullname" . }}-localtime
184         hostPath:
185           path: /etc/localtime
186       - name: {{ include "common.fullname" . }}-filebeat-conf
187         configMap:
188           name: {{ include "common.release" . }}-sdc-filebeat-configmap
189       - name: {{ include "common.fullname" . }}-data-filebeat
190         emptyDir: {}
191       - name: {{ include "common.fullname" . }}-logback
192         configMap:
193           name : {{ include "common.fullname" . }}-logging-configmap
194       - name: {{ include "common.fullname" . }}-environments
195         configMap:
196           name: {{ include "common.release" . }}-sdc-environments-configmap
197           defaultMode: 0755
198       - name: sdc-environments-output
199         emptyDir: { medium: "Memory" }
200       - name:  {{ include "common.fullname" . }}-logs
201         emptyDir: {}
202       - name:  {{ include "common.fullname" . }}-cert-storage
203         persistentVolumeClaim:
204           claimName: {{ include "common.fullname" . }}-cert
205       imagePullSecrets:
206       - name: "{{ include "common.namespace" . }}-docker-registry-key"