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