d731a56c5cb1f049ae0afe9c0b9b981ab913770d
[oom.git] / kubernetes / sdc / components / sdc-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: {{- include "common.resourceMetadata" . | nindent 2 }}
21 spec:
22   selector: {{- include "common.selectors" . | nindent 4 }}
23   replicas: {{ .Values.replicaCount }}
24   template:
25     metadata: {{- include "common.templateMetadata" . | nindent 6 }}
26     spec:
27       initContainers: {{ include "common.certInitializer.initContainer" . | nindent 6 }}
28       - name: {{ include "common.name" . }}-readiness
29         command:
30         - /app/ready.py
31         args:
32         - --container-name
33         - "sdc-onboarding-be"
34         env:
35         - name: NAMESPACE
36           valueFrom:
37             fieldRef:
38               apiVersion: v1
39               fieldPath: metadata.namespace
40         image: {{ include "repositoryGenerator.image.readiness" . }}
41         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
42         resources:
43           limits:
44             cpu: 100m
45             memory: 100Mi
46           requests:
47             cpu: 3m
48             memory: 20Mi
49       - name: {{ include "common.name" . }}-job-completion
50         image: {{ include "repositoryGenerator.image.readiness" . }}
51         imagePullPolicy: "{{ .Values.global.pullPolicy | default .Values.pullPolicy }}"
52         command:
53         - /app/ready.py
54         args:
55         - --job-name
56         - {{ include "common.release" . }}-sdc-onboarding-be-cassandra-init
57         env:
58         - name: NAMESPACE
59           valueFrom:
60             fieldRef:
61               apiVersion: v1
62               fieldPath: metadata.namespace
63         resources:
64           limits:
65             cpu: 100m
66             memory: 100Mi
67           requests:
68             cpu: 3m
69             memory: 20Mi
70       {{- if .Values.global.aafEnabled }}
71       - name: {{ include "common.name" . }}-update-config
72         image: {{ include "repositoryGenerator.image.envsubst" . }}
73         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
74         command:
75         - sh
76         args:
77         - "-c"
78         - |
79           export $(grep '^c' {{ .Values.certInitializer.credsPath }}/mycreds.prop | xargs -0)
80           export KEYSTORE_PASS=$cadi_keystore_password_p12
81           export KEYMANAGER_PASS=$cadi_keystore_password_p12
82           export TRUSTSTORE_PASS=$cadi_truststore_password
83           cp {{ .Values.certInitializer.credsPath }}/{{ .Values.certInitializer.keystoreFile }} /config-output
84           cp {{ .Values.certInitializer.credsPath }}/{{ .Values.certInitializer.truststoreFile }} /config-output
85           cd /config-input && \
86           for PFILE in `find . -not -type d | grep -v -F ..`
87           do
88             envsubst <${PFILE} >/config-output/${PFILE}
89             chmod 0755 /config-output/${PFILE}
90           done
91         resources:
92           limits:
93             cpu: 100m
94             memory: 100Mi
95           requests:
96             cpu: 3m
97             memory: 20Mi
98         volumeMounts: {{ include "common.certInitializer.volumeMount" . | nindent 8 }}
99         - name: {{ include "common.fullname" . }}-environments
100           mountPath: /config-input/
101         - name: sdc-environments-output
102           mountPath: /config-output/
103       {{- end }}
104       containers:
105         - name: {{ include "common.name" . }}
106           image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
107           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
108           {{- if .Values.global.aafEnabled }}
109           command:
110           - sh
111           args:
112           - "-c"
113           - |
114             sed -i '/trustStorePassword/d' ${JETTY_BASE}/startup.sh
115             ${JETTY_BASE}/startup.sh
116           {{- end }}
117           ports: {{ include "common.containerPorts" . | nindent 10  }}
118           {{ if eq .Values.liveness.enabled true }}
119           livenessProbe:
120             httpGet:
121               path: /sdc2/rest/healthCheck
122               port: {{ .Values.service.internalPort }}
123             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
124             periodSeconds: {{ .Values.liveness.periodSeconds }}
125             timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
126             successThreshold: {{ .Values.liveness.successThreshold }}
127             failureThreshold: {{ .Values.liveness.failureThreshold }}
128           {{ end }}
129           readinessProbe:
130             httpGet:
131               path: /sdc2/rest/healthCheck
132               port: {{ .Values.service.internalPort }}
133             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
134             periodSeconds: {{ .Values.readiness.periodSeconds }}
135             timeoutSeconds: {{ .Values.readiness.timeoutSeconds }}
136             successThreshold: {{ .Values.readiness.successThreshold }}
137             failureThreshold: {{ .Values.readiness.failureThreshold }}
138           resources: {{ include "common.resources" . | nindent 12 }}
139           startupProbe:
140             httpGet:
141               path: /sdc2/rest/healthCheck
142               port: {{ .Values.service.internalPort }}
143             initialDelaySeconds: {{ .Values.startup.initialDelaySeconds }}
144             periodSeconds: {{ .Values.startup.periodSeconds }}
145             timeoutSeconds: {{ .Values.startup.timeoutSeconds }}
146             successThreshold: {{ .Values.startup.successThreshold }}
147             failureThreshold: {{ .Values.startup.failureThreshold }}
148           resources: {{ include "common.resources" . | nindent 12 }}
149           env:
150           - name: ENVNAME
151             value: {{ .Values.env.name }}
152           - name: JAVA_OPTIONS
153             value: {{ .Values.config.javaOptions }}
154           - name: cassandra_ssl_enabled
155             value: {{ .Values.config.cassandraSslEnabled | quote }}
156           - name: HOST_IP
157             valueFrom:
158               fieldRef:
159                 fieldPath: status.podIP
160           volumeMounts:
161           - name: sdc-environments-output
162             mountPath: /app/jetty/chef-solo/environments/
163           - name: sdc-environments-output
164             mountPath: /app/jetty/chef-solo/cookbooks/sdc-catalog-be/files/default/org.onap.sdc.p12
165             subPath: org.onap.sdc.p12
166           - name: sdc-environments-output
167             mountPath: /app/jetty/chef-solo/cookbooks/sdc-catalog-be/files/default/org.onap.sdc.trust.jks
168             subPath: org.onap.sdc.trust.jks
169           - name: {{ include "common.fullname" . }}-localtime
170             mountPath: /etc/localtime
171             readOnly: true
172           - name: {{ include "common.fullname" . }}-logs
173             mountPath: /var/log/onap
174           - name: {{ include "common.fullname" . }}-logback
175             mountPath: /tmp/logback.xml
176             subPath: logback.xml
177           lifecycle:
178             postStart:
179               exec:
180                 command: ["/bin/sh", "-c", "export LOG=wait_logback.log; touch $LOG; export SRC=/tmp/logback.xml; export DST=/app/jetty/config/catalog-be/; while [ ! -e $DST ]; do echo 'Waiting for $DST...' >> $LOG; sleep 5; done; sleep 2; /bin/cp -f $SRC $DST; echo 'Done' >> $LOG"]
181         # side car containers
182         - name: {{ include "common.name" . }}-filebeat-onap
183           image: {{ include "repositoryGenerator.image.logging" . }}
184           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
185           volumeMounts:
186           - name: {{ include "common.fullname" . }}-filebeat-conf
187             mountPath: /usr/share/filebeat/filebeat.yml
188             subPath: filebeat.yml
189           - name: {{ include "common.fullname" . }}-logs
190             mountPath: /var/log/onap
191           - name: {{ include "common.fullname" . }}-data-filebeat
192             mountPath: /usr/share/filebeat/data
193           resources:
194             limits:
195               cpu: 100m
196               memory: 100Mi
197             requests:
198               cpu: 3m
199               memory: 20Mi
200       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
201       volumes: {{ include "common.certInitializer.volumes" . | nindent 6 }}
202       - name: {{ include "common.fullname" . }}-localtime
203         hostPath:
204           path: /etc/localtime
205       - name: {{ include "common.fullname" . }}-filebeat-conf
206         configMap:
207           name: {{ include "common.release" . }}-sdc-filebeat-configmap
208       - name: {{ include "common.fullname" . }}-data-filebeat
209         emptyDir: {}
210       - name: {{ include "common.fullname" . }}-logback
211         configMap:
212           name : {{ include "common.fullname" . }}-logging-configmap
213       - name: {{ include "common.fullname" . }}-environments
214         configMap:
215           name: {{ include "common.release" . }}-sdc-environments-configmap
216           defaultMode: 0755
217       - name: sdc-environments-output
218         emptyDir: { medium: "Memory" }
219       - name: {{ include "common.fullname" . }}-logs
220         emptyDir: {}
221       imagePullSecrets:
222       - name: "{{ include "common.namespace" . }}-docker-registry-key"