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