[AAI][SPARKY] Automatically retrieve certs
[oom.git] / kubernetes / aai / components / aai-sparky-be / templates / deployment.yaml
1 {{/*
2 # Copyright (c) 2017 Amdocs, Bell Canada
3 # Modifications Copyright (c) 2018 AT&T
4 # Modifications Copyright (c) 2020 Nokia
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   replicas: {{ .Values.replicaCount }}
31   selector:
32     matchLabels:
33       app: {{ include "common.name" . }}
34   template:
35     metadata:
36       labels:
37         app: {{ include "common.name" . }}
38         release: {{ include "common.release" . }}
39       name: {{ include "common.name" . }}
40     spec:
41       initContainers: {{ include "common.certInitializer.initContainer" . | nindent 6 }}
42       - command:
43         - sh
44         args:
45         - -c
46         - |
47           echo "*** retrieve Truststore and Keystore password"
48           export $(cat {{ .Values.certInitializer.credsPath }}/mycreds.prop \
49             | xargs -0)
50           echo "*** write them in portal part"
51           cd /config-input
52           for PFILE in `ls -1 .`
53             do
54               envsubst <${PFILE} >/config/${PFILE}
55           done
56         volumeMounts: {{ include "common.certInitializer.volumeMount" . | nindent 8 }}
57         - mountPath: /config-input
58           name: portal-config-input
59         - mountPath: /config
60           name: portal-config
61         image: {{ include "repositoryGenerator.image.envsubst" . }}
62         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
63         name: {{ include "common.name" . }}-update-config
64       - command:
65         - /app/ready.py
66         args:
67         - --container-name
68         - aai
69         env:
70         - name: NAMESPACE
71           valueFrom:
72             fieldRef:
73               apiVersion: v1
74               fieldPath: metadata.namespace
75         image: {{ include "repositoryGenerator.image.readiness" . }}
76         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
77         name: {{ include "common.name" . }}-readiness
78       containers:
79       - name: {{ include "common.name" . }}
80         image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
81         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
82         command:
83         - sh
84         args:
85         - -c
86         - |
87           echo "*** retrieve Truststore and Keystore password"
88           export $(cat {{ .Values.certInitializer.credsPath }}/mycreds.prop \
89             | xargs -0)
90           echo "*** actual launch of AAI Sparky BE"
91           /opt/app/sparky/bin/start.sh
92         volumeMounts: {{ include "common.certInitializer.volumeMount" . | nindent 8 }}
93         - mountPath: /etc/localtime
94           name: localtime
95           readOnly: true
96         - mountPath: /opt/app/sparky/config/auth/csp-cookie-filter.properties
97           name: auth-config
98           subPath: csp-cookie-filter.properties
99         - mountPath: /opt/app/sparky/config/portal/
100           name: portal-config
101         - mountPath: /opt/app/sparky/config/portal/BOOT-INF/classes/
102           name: portal-config-props
103         - mountPath: /var/log/onap
104           name: logs
105         - mountPath:  /opt/app/sparky/config/application.properties
106           name: config
107           subPath: application.properties
108         - mountPath:  /opt/app/sparky/config/application-resources.properties
109           name: config
110           subPath: application-resources.properties
111         - mountPath:  /opt/app/sparky/config/application-ssl.properties
112           name: config
113           subPath: application-ssl.properties
114         - mountPath:  /opt/app/sparky/config/application-oxm-default.properties
115           name: config
116           subPath: application-oxm-default.properties
117         - mountPath:  /opt/app/sparky/config/application-oxm-override.properties
118           name: config
119           subPath: application-oxm-override.properties
120         - mountPath:  /opt/app/sparky/config/application-oxm-schema-prod.properties
121           name: config
122           subPath: application-oxm-schema-prod.properties
123         - mountPath:  /opt/app/sparky/config/roles.config
124           name: config
125           subPath: roles.config
126         - mountPath:  /opt/app/sparky/config/users.config
127           name: config
128           subPath: users.config
129         - mountPath:  /opt/app/sparky/config/logging/logback.xml
130           name: config
131           subPath: logback.xml
132         ports:
133         - containerPort: {{ .Values.service.internalPort }}
134         # disable liveness probe when breakpoints set in debugger
135         # so K8s doesn't restart unresponsive container
136         {{- if eq .Values.liveness.enabled true }}
137         livenessProbe:
138           tcpSocket:
139             port: {{ .Values.service.internalPort }}
140           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
141           periodSeconds: {{ .Values.liveness.periodSeconds }}
142         {{ end -}}
143         readinessProbe:
144           tcpSocket:
145             port: {{ .Values.service.internalPort }}
146           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
147           periodSeconds: {{ .Values.readiness.periodSeconds }}
148         resources:
149 {{ include "common.resources" . }}
150       {{- if .Values.nodeSelector }}
151       nodeSelector:
152 {{ toYaml .Values.nodeSelector | indent 8 }}
153       {{- end -}}
154       {{- if .Values.affinity }}
155       affinity:
156 {{ toYaml .Values.affinity | indent 8 }}
157       {{- end }}
158
159       # side car containers
160       - name: filebeat-onap
161         image: {{ include "repositoryGenerator.image.logging" . }}
162         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
163         volumeMounts:
164         - mountPath: /usr/share/filebeat/filebeat.yml
165           subPath: filebeat.yml
166           name: filebeat-conf
167         - mountPath: /var/log/onap
168           name: logs
169         - mountPath: /usr/share/filebeat/data
170           name: aai-sparky-filebeat
171         resources:
172 {{ include "common.resources" . }}
173
174       volumes: {{ include "common.certInitializer.volumes" . | nindent 6 }}
175       - name: localtime
176         hostPath:
177           path: /etc/localtime
178       - name: config
179         configMap:
180           name: {{ include "common.fullname" . }}
181       - name: portal-config
182         emptyDir:
183           medium: Memory
184       - name: portal-config-input
185         configMap:
186           name: {{ include "common.fullname" . }}-portal
187       - name: portal-config-props
188         configMap:
189           name: {{ include "common.fullname" . }}-portal-props
190       - name: auth-config
191         secret:
192           secretName: {{ include "common.fullname" . }}
193       - name: filebeat-conf
194         configMap:
195           name: aai-filebeat
196       - name: logs
197         emptyDir: {}
198       - name: aai-sparky-filebeat
199         emptyDir: {}
200       - name: modeldir
201         emptyDir: {}
202       restartPolicy: {{ .Values.global.restartPolicy | default .Values.restartPolicy }}
203       imagePullSecrets:
204       - name: "{{ include "common.namespace" . }}-docker-registry-key"