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