[SDC] use of certInitializer template
[oom.git] / kubernetes / sdc / components / sdc-dcae-fe / templates / deployment.yaml
1 # Copyright © 2018 Amdocs, AT&T, Bell Canada
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #       http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 apiVersion: apps/v1
16 kind: Deployment
17 metadata:
18   name: {{ include "common.fullname" . }}
19   namespace: {{ include "common.namespace" . }}
20   labels:
21     app: {{ include "common.name" . }}
22     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
23     release: {{ include "common.release" . }}
24     heritage: {{ .Release.Service }}
25 spec:
26   selector:
27     matchLabels:
28       app: {{ include "common.name" . }}
29   replicas: {{ .Values.replicaCount }}
30   template:
31     metadata:
32       labels:
33         app: {{ include "common.name" . }}
34         release: {{ include "common.release" . }}
35     spec:
36       initContainers: {{ include "common.certInitializer.initContainer" . | nindent 6 }}
37       - name: {{ include "common.name" . }}-readiness
38         command:
39         - /app/ready.py
40         args:
41         - --container-name
42         - sdc-dcae-be
43         env:
44         - name: NAMESPACE
45           valueFrom:
46             fieldRef:
47               apiVersion: v1
48               fieldPath: metadata.namespace
49         image: "{{ include "common.repository" . }}/{{ .Values.global.readinessImage }}"
50         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
51       - name: {{ include "common.name" . }}-job-completion
52         image: "{{ include "common.repository" . }}/{{ .Values.global.readinessImage }}"
53         imagePullPolicy: "{{ .Values.global.pullPolicy | default .Values.pullPolicy }}"
54         command:
55         - /app/ready.py
56         args:
57         - --job-name
58         - {{ include "common.release" . }}-sdc-dcae-be-tools
59         env:
60         - name: NAMESPACE
61           valueFrom:
62             fieldRef:
63               apiVersion: v1
64               fieldPath: metadata.namespace
65       {{- if .Values.global.aafEnabled }}
66       - name: {{ include "common.name" . }}-update-config
67         image: "{{ .Values.global.envsubstImage }}"
68         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
69         command:
70         - sh
71         args:
72         - "-c"
73         - |
74           export $(grep '^c' {{ .Values.certInitializer.credsPath }}/mycreds.prop | xargs -0)
75           export KEYSTORE_PASS=$cadi_keystore_password_p12
76           export KEYMANAGER_PASS=$cadi_keystore_password_p12
77           export TRUSTSTORE_PASS=$cadi_truststore_password
78           cp {{ .Values.certInitializer.credsPath }}/{{ .Values.certInitializer.keystoreFile }} /config-output
79           cp {{ .Values.certInitializer.credsPath }}/{{ .Values.certInitializer.truststoreFile }} /config-output
80           cd /config-input && \
81           for PFILE in `find . -not -type d | grep -v -F ..`
82           do
83             envsubst <${PFILE} >/config-output/${PFILE}
84             chmod 0755 /config-output/${PFILE}
85           done
86         volumeMounts: {{ include "common.certInitializer.volumeMount" . | nindent 10 }}
87           - name: {{ include "common.fullname" . }}-environments
88             mountPath: /config-input/
89           - name: sdc-environments-output
90             mountPath: /config-output/
91       {{- end }}
92       containers:
93         - name: {{ include "common.name" . }}
94           image: "{{ include "common.repository" . }}/{{ .Values.image }}"
95           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
96           ports:
97           - containerPort: {{ .Values.service.internalPort }}
98           {{ if eq .Values.liveness.enabled true }}
99           livenessProbe:
100             tcpSocket:
101               port: {{ .Values.service.internalPort }}
102             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
103             periodSeconds: {{ .Values.liveness.periodSeconds }}
104           {{ end }}
105           readinessProbe:
106             httpGet:
107               path: /dcaed/healthCheck
108               port: {{ .Values.service.internalPort }}
109               scheme: HTTPS
110             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
111             periodSeconds: {{ .Values.readiness.periodSeconds }}
112           env:
113           - name: ENVNAME
114             value: {{ .Values.env.name }}
115           - name: JAVA_OPTIONS
116             value: {{ .Values.config.javaOptions }}
117           - name: HOST_IP
118             valueFrom:
119               fieldRef:
120                 fieldPath: status.podIP
121           volumeMounts:
122           - name: sdc-environments-output
123             mountPath: /var/lib/jetty/chef-solo/environments/
124           - name: sdc-environments-output
125             mountPath: /var/lib/jetty/chef-solo/cookbooks/Deploy-DCAE/files/default/org.onap.sdc.p12
126             subPath: org.onap.sdc.p12
127           - name: sdc-environments-output
128             mountPath: /var/lib/jetty/chef-solo/cookbooks/Deploy-DCAE/files/default/org.onap.sdc.trust.jks
129             subPath: org.onap.sdc.trust.jks
130           - name: {{ include "common.fullname" . }}-localtime
131             mountPath: /etc/localtime
132             readOnly: true
133           - name: {{ include "common.fullname" . }}-logs
134             mountPath: /var/lib/jetty/logs
135           - name: {{ include "common.fullname" . }}-logback
136             mountPath: /tmp/logback.xml
137             subPath: logback.xml
138           lifecycle:
139             postStart:
140               exec:
141                 command: ["/bin/sh", "-c", "export LOG=wait_logback.log; touch $LOG; export SRC=/tmp/logback.xml; export DST=/var/lib/jetty/config/dcae-fe/; while [ ! -e $DST ]; do echo 'Waiting for $DST...' >> $LOG; sleep 5; done; sleep 2; /bin/cp -f $SRC $DST; echo 'Done' >> $LOG"]
142           resources:
143 {{ include "common.resources" . | indent 12 }}
144         {{- if .Values.nodeSelector }}
145         nodeSelector:
146 {{ toYaml .Values.nodeSelector | indent 10 }}
147         {{- end -}}
148         {{- if .Values.affinity }}
149         affinity:
150 {{ toYaml .Values.affinity | indent 10 }}
151         {{- end }}
152
153         # side car containers
154         - name: {{ include "common.name" . }}-filebeat-onap
155           image: "{{ .Values.global.loggingRepository }}/{{ .Values.global.loggingImage }}"
156           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
157           volumeMounts:
158           - name: {{ include "common.fullname" . }}-filebeat-conf
159             mountPath: /usr/share/filebeat/filebeat.yml
160             subPath: filebeat.yml
161           - name: {{ include "common.fullname" . }}-logs
162             mountPath: /var/log/onap
163           - name: {{ include "common.fullname" . }}-data-filebeat
164             mountPath: /usr/share/filebeat/data
165       volumes: {{ include "common.certInitializer.volumes" . | nindent 8 }}
166         - name: {{ include "common.fullname" . }}-localtime
167           hostPath:
168             path: /etc/localtime
169         - name: {{ include "common.fullname" . }}-filebeat-conf
170           configMap:
171             name: {{ include "common.release" . }}-sdc-filebeat-configmap
172         - name: {{ include "common.fullname" . }}-data-filebeat
173           emptyDir: {}
174         - name: {{ include "common.fullname" . }}-logback
175           configMap:
176             name : {{ include "common.fullname" . }}-logging-configmap
177         - name: {{ include "common.fullname" . }}-environments
178           configMap:
179             name: {{ include "common.release" . }}-sdc-environments-configmap
180             defaultMode: 0755
181         - name: sdc-environments-output
182           emptyDir: { medium: "Memory" }
183         - name: {{ include "common.fullname" . }}-logs
184           emptyDir: {}
185       imagePullSecrets:
186       - name: "{{ include "common.namespace" . }}-docker-registry-key"