Merge "[AAI] Add model-loader tracing config"
[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 # Modifications Copyright © 2021  Orange
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 #       http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 */}}
18
19 apiVersion: apps/v1
20 kind: Deployment
21 metadata:
22   name: {{ include "common.fullname" . }}
23   namespace: {{ include "common.namespace" . }}
24   labels:
25     app: {{ include "common.name" . }}
26     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
27     release: {{ include "common.release" . }}
28     heritage: {{ .Release.Service }}
29 spec:
30   selector:
31     matchLabels:
32       app: {{ include "common.name" . }}
33   replicas: {{ .Values.replicaCount }}
34   template:
35     metadata:
36       labels:
37         app: {{ include "common.name" . }}
38         release: {{ include "common.release" . }}
39     spec:
40       initContainers: {{ include "common.certInitializer.initContainer" . | nindent 6 }}
41       - name: {{ include "common.name" . }}-job-completion
42         image: {{ include "repositoryGenerator.image.readiness" . }}
43         imagePullPolicy: "{{ .Values.global.pullPolicy | default .Values.pullPolicy }}"
44         command:
45         - /app/ready.py
46         args:
47         - --job-name
48         - {{ include "common.release" . }}-sdc-onboarding-be-cassandra-init
49         env:
50         - name: NAMESPACE
51           valueFrom:
52             fieldRef:
53               apiVersion: v1
54               fieldPath: metadata.namespace
55         resources:
56           limits:
57             cpu: 100m
58             memory: 100Mi
59           requests:
60             cpu: 3m
61             memory: 20Mi
62       {{- if .Values.global.aafEnabled }}
63       - name: {{ include "common.name" . }}-update-config
64         image: {{ include "repositoryGenerator.image.envsubst" . }}
65         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
66         command:
67         - sh
68         args:
69         - "-c"
70         - |
71           export $(grep '^c' {{ .Values.certInitializer.credsPath }}/mycreds.prop | xargs -0)
72           export KEYSTORE_PASS=$cadi_keystore_password_p12
73           export KEYMANAGER_PASS=$cadi_keystore_password_p12
74           export TRUSTSTORE_PASS=$cadi_truststore_password
75           cp {{ .Values.certInitializer.credsPath }}/{{ .Values.certInitializer.keystoreFile }} /config-output
76           cp {{ .Values.certInitializer.credsPath }}/{{ .Values.certInitializer.truststoreFile }} /config-output
77           cd /config-input && \
78           for PFILE in `find . -not -type d | grep -v -F ..`
79           do
80             envsubst <${PFILE} >/config-output/${PFILE}
81             chmod 0755 /config-output/${PFILE}
82           done
83         volumeMounts: {{ include "common.certInitializer.volumeMount" . | nindent 10 }}
84           - name: sdc-environments-input
85             mountPath: /config-input/
86           - name: sdc-environments
87             mountPath: /config-output/
88         resources:
89           limits:
90             cpu: 100m
91             memory: 100Mi
92           requests:
93             cpu: 3m
94             memory: 20Mi
95       {{- end }}
96       - name: volume-permissions
97         image: {{ include "repositoryGenerator.image.busybox" . }}
98         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
99         command:
100           - sh
101         args:
102           - "-c"
103           - |
104             chown -R {{ .Values.securityContext.runAsUser }}:{{ .Values.securityContext.fsGroup }} //onboard/cert
105         securityContext:
106           runAsUser: 0
107         volumeMounts:
108           - name: cert-storage
109             mountPath: "/onboard/cert"
110         resources:
111           limits:
112             cpu: 100m
113             memory: 100Mi
114           requests:
115             cpu: 3m
116             memory: 20Mi
117       containers:
118         - name: {{ include "common.name" . }}
119           image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
120           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
121           ports:
122           - containerPort: {{ .Values.service.internalPort }}
123           - containerPort: {{ .Values.service.internalPort2 }}
124           {{ if eq .Values.liveness.enabled true }}
125           livenessProbe:
126             httpGet:
127               path: /onboarding-api/v1.0/healthcheck
128               port: {{ .Values.service.internalPort2 }}
129             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
130             periodSeconds: {{ .Values.liveness.periodSeconds }}
131             timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
132             successThreshold: {{ .Values.liveness.successThreshold }}
133             failureThreshold: {{ .Values.liveness.failureThreshold }}
134           {{ end }}
135           readinessProbe:
136             httpGet:
137               path: /onboarding-api/v1.0/healthcheck
138               port: {{ .Values.service.internalPort2 }}
139             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
140             periodSeconds: {{ .Values.readiness.periodSeconds }}
141             timeoutSeconds: {{ .Values.readiness.timeoutSeconds }}
142             successThreshold: {{ .Values.readiness.successThreshold }}
143             failureThreshold: {{ .Values.readiness.failureThreshold }}
144           startupProbe:
145             httpGet:
146               path: /onboarding-api/v1.0/healthcheck
147               port: {{ .Values.service.internalPort2 }}
148             initialDelaySeconds: {{ .Values.startup.initialDelaySeconds }}
149             periodSeconds: {{ .Values.startup.periodSeconds }}
150             timeoutSeconds: {{ .Values.startup.timeoutSeconds }}
151             successThreshold: {{ .Values.startup.successThreshold }}
152             failureThreshold: {{ .Values.startup.failureThreshold }}
153           resources: {{ include "common.resources" . | nindent 12 }}
154           env:
155           - name: ENVNAME
156             value: {{ .Values.env.name }}
157           - name: JAVA_OPTIONS
158             value: {{ .Values.config.javaOptions }}
159           - name: SDC_CLUSTER_NAME
160             value: "SDC-CS-{{ .Values.env.name }}"
161           - name: cassandra_ssl_enabled
162             value: {{ .Values.config.cassandraSslEnabled | quote }}
163           - name: HOST_IP
164             valueFrom:
165               fieldRef:
166                 fieldPath: status.podIP
167           - name: SDC_USER
168             valueFrom:
169               secretKeyRef: {name: {{ include "common.release" . }}-sdc-cs-secrets, key: sdc_user}
170           - name: SDC_PASSWORD
171             valueFrom:
172               secretKeyRef: {name: {{ include "common.release" . }}-sdc-cs-secrets, key: sdc_password}
173           - name: SDC_CERT_DIR
174             value: {{ .Values.cert.certDir }}
175           volumeMounts:
176           - name: sdc-environments
177             mountPath: /app/jetty/chef-solo/environments/
178           {{- if .Values.global.aafEnabled }}
179           - name: sdc-environments
180             mountPath: /app/jetty/chef-solo/cookbooks/sdc-onboard-backend/files/default/org.onap.sdc.p12
181             subPath: org.onap.sdc.p12
182           - name: sdc-environments
183             mountPath: /app/jetty/chef-solo/cookbooks/sdc-onboard-backend/files/default/org.onap.sdc.trust.jks
184             subPath: org.onap.sdc.trust.jks
185           {{- end }}
186           - name: localtime
187             mountPath: /etc/localtime
188             readOnly: true
189           - name: logs
190             mountPath: /var/log/onap
191           - name: cert-storage
192             mountPath: "{{ .Values.cert.certDir }}"
193           - name: logback
194             mountPath: /tmp/logback.xml
195             subPath: logback.xml
196           lifecycle:
197             postStart:
198               exec:
199                 command: ["/bin/sh", "-c", "export LOG=wait_logback.log; touch $LOG; export SRC=/tmp/logback.xml; export DST=/app/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"]
200         # side car containers
201         {{ include "common.log.sidecar" . | nindent 8 }}
202       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
203       volumes: {{ include "common.certInitializer.volumes" . | nindent 6 }}
204       - name: localtime
205         hostPath:
206           path: /etc/localtime
207
208       {{ include "common.log.volumes" (dict "dot" . "configMapNamePrefix" (tpl .Values.logConfigMapNamePrefix .)) | nindent 6 }}
209       - name: logback
210         configMap:
211           name : {{ include "common.fullname" . }}-logging-configmap
212       - name: sdc-environments
213       {{- if .Values.global.aafEnabled }}
214         emptyDir: { medium: "Memory" }
215       - name: sdc-environments-input
216       {{- end }}
217         configMap:
218           name: {{ include "common.release" . }}-sdc-environments-configmap
219           defaultMode: 0755
220       - name:  logs
221         emptyDir: {}
222       - name:  cert-storage
223         persistentVolumeClaim:
224           claimName: {{ include "common.fullname" . }}-cert
225       imagePullSecrets:
226       - name: "{{ include "common.namespace" . }}-docker-registry-key"