Merge "Add Pluggable Security to aai-resources"
[oom.git] / kubernetes / aai / charts / aai-champ / templates / deployment.yaml
1 # Copyright © 2018 Amdocs, AT&T
2 # Modifications Copyright © 2018 Bell Canada
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #       http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 apiVersion: extensions/v1beta1
17 kind: Deployment
18 metadata:
19   name: {{ include "common.fullname" . }}
20   namespace: {{ include "common.namespace" . }}
21   labels:
22     app: {{ include "common.name" . }}
23     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
24     release: {{ .Release.Name }}
25     heritage: {{ .Release.Service }}
26 spec:
27   replicas: {{ .Values.replicaCount }}
28   template:
29     metadata:
30       labels:
31         app: {{ include "common.name" . }}
32         release: {{ .Release.Name }}
33     spec:
34     {{ if .Values.global.installSidecarSecurity }}
35       hostAliases:
36       - ip: {{ .Values.global.aaf.serverIp }}
37         hostnames:
38         - {{ .Values.global.aaf.serverHostname }}
39     {{ end }}
40       initContainers:
41         - command:
42           - /root/ready.py
43           args:
44           - --container-name
45           - aai-cassandra
46           env:
47           - name: NAMESPACE
48             valueFrom:
49               fieldRef:
50                 apiVersion: v1
51                 fieldPath: metadata.namespace
52           image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
53           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
54           name: {{ include "common.name" . }}-readiness
55     {{ if .Values.global.installSidecarSecurity }}
56         - name: {{ .Values.global.tproxyConfig.name }}
57           image: "{{ include "common.repository" . }}/{{ .Values.global.tproxyConfig.image }}"
58           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
59           securityContext:
60             privileged: true
61     {{ end }}
62       containers:
63         - name: {{ include "common.name" . }}
64           image: "{{ include "common.repository" . }}/{{ .Values.image }}"
65           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
66           ports:
67           - containerPort: {{ .Values.service.internalPort }}
68           # disable liveness probe when breakpoints set in debugger
69           # so K8s doesn't restart unresponsive container
70           {{ if .Values.liveness.enabled }}
71           livenessProbe:
72             tcpSocket:
73               port: {{ .Values.service.internalPort }}
74             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
75             periodSeconds: {{ .Values.liveness.periodSeconds }}
76           {{ end }}
77           readinessProbe:
78             tcpSocket:
79               port: {{ .Values.service.internalPort }}
80             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
81             periodSeconds: {{ .Values.readiness.periodSeconds }}
82           env:
83             - name: CONFIG_HOME
84               value: "/opt/app/champ-service/appconfig"
85             - name: GRAPHIMPL
86               value: "janus-deps"
87             - name: KEY_STORE_PASSWORD
88               valueFrom:
89                 secretKeyRef:
90                   name: {{ template "common.fullname" . }}-pass
91                   key: KEY_STORE_PASSWORD
92             - name: KEY_MANAGER_PASSWORD
93               valueFrom:
94                 secretKeyRef:
95                   name: {{ template "common.fullname" . }}-pass
96                   key: KEY_MANAGER_PASSWORD
97             - name: SERVICE_BEANS
98               value: "/opt/app/champ-service/dynamic/conf"
99           volumeMounts:
100           - mountPath: /etc/localtime
101             name: localtime
102             readOnly: true
103           - mountPath: /opt/app/champ-service/appconfig/champ-api.properties
104             name: {{ include "common.fullname" . }}-config
105             subPath: champ-api.properties
106           - mountPath: /opt/app/champ-service/appconfig/auth
107             name: {{ include "common.fullname" . }}-secrets
108           - mountPath: /opt/app/champ-service/dynamic/conf/champ-beans.xml
109             name: {{ include "common.fullname" . }}-dynamic-config
110             subPath: champ-beans.xml
111           - mountPath: /opt/app/champ-service/bundleconfig/etc/logback.xml
112             name: {{ include "common.fullname" . }}-logback-config
113             subPath: logback.xml
114           - mountPath: /var/log/onap
115             name: {{ include "common.fullname" . }}-logs
116           resources:
117 {{ include "common.resources" . | indent 12 }}
118         {{- if .Values.nodeSelector }}
119         nodeSelector:
120 {{ toYaml .Values.nodeSelector | indent 10 }}
121         {{- end -}}
122         {{- if .Values.affinity }}
123         affinity:
124 {{ toYaml .Values.affinity | indent 10 }}
125         {{- end }}
126
127         # side car containers
128         - name: filebeat-onap
129           image: "{{ .Values.global.loggingRepository }}/{{ .Values.global.loggingImage }}"
130           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
131           volumeMounts:
132           - mountPath: /usr/share/filebeat/filebeat.yml
133             subPath: filebeat.yml
134             name: filebeat-conf
135           - mountPath: /var/log/onap
136             name: {{ include "common.fullname" . }}-logs
137           - mountPath: /usr/share/filebeat/data
138             name: aai-filebeat
139     {{ if .Values.global.installSidecarSecurity }}
140         - name: {{ .Values.global.rproxy.name }}
141           image: "{{ include "common.repository" . }}/{{ .Values.global.rproxy.image }}"
142           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
143           env:
144           - name: CONFIG_HOME
145             value: "/opt/app/rproxy/config"
146           - name: KEY_STORE_PASSWORD
147             value: {{ .Values.config.keyStorePassword }} 
148           - name: spring_profiles_active
149             value: {{ .Values.global.rproxy.activeSpringProfiles }}
150           volumeMounts:
151           - name: {{ include "common.fullname" . }}-rproxy-config
152             mountPath: /opt/app/rproxy/config/forward-proxy.properties
153             subPath: forward-proxy.properties
154           - name: {{ include "common.fullname" . }}-rproxy-config
155             mountPath: /opt/app/rproxy/config/primary-service.properties
156             subPath: primary-service.properties
157           - name: {{ include "common.fullname" . }}-rproxy-config
158             mountPath: /opt/app/rproxy/config/reverse-proxy.properties
159             subPath: reverse-proxy.properties
160           - name: {{ include "common.fullname" . }}-rproxy-config
161             mountPath: /opt/app/rproxy/config/cadi.properties
162             subPath: cadi.properties
163           - name: {{ include "common.fullname" . }}-rproxy-log-config
164             mountPath: /opt/app/rproxy/config/logback-spring.xml
165             subPath: logback-spring.xml
166           - name: {{ include "common.fullname" . }}-rproxy-auth-config
167             mountPath: /opt/app/rproxy/config/auth/tomcat_keystore
168             subPath: tomcat_keystore
169           - name: {{ include "common.fullname" . }}-rproxy-auth-config
170             mountPath: /opt/app/rproxy/config/auth/client-cert.p12
171             subPath: client-cert.p12
172           - name: {{ include "common.fullname" . }}-rproxy-auth-config
173             mountPath: /opt/app/rproxy/config/auth/uri-authorization.json
174             subPath: uri-authorization.json
175           #- name: {{ include "common.fullname" . }}-rproxy-auth-config
176           #  mountPath: /opt/app/rproxy/config/auth/aaf_truststore.jks
177           #  subPath: aaf_truststore.jks
178           - name: {{ include "common.fullname" . }}-rproxy-security-config
179             mountPath: /opt/app/rproxy/config/security/keyfile
180             subPath: keyfile
181
182           ports:
183           - containerPort: {{ .Values.global.rproxy.port }}
184
185         - name: {{ .Values.global.fproxy.name }}
186           image: "{{ include "common.repository" . }}/{{ .Values.global.fproxy.image }}"
187           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
188           env:
189           - name: CONFIG_HOME
190             value: "/opt/app/fproxy/config"
191           - name: KEY_STORE_PASSWORD
192             value: {{ .Values.config.keyStorePassword }} 
193           - name: spring_profiles_active
194             value: {{ .Values.global.fproxy.activeSpringProfiles }}
195           volumeMounts:
196           - name: {{ include "common.fullname" . }}-fproxy-config
197             mountPath: /opt/app/fproxy/config/fproxy.properties
198             subPath: fproxy.properties
199           - name: {{ include "common.fullname" . }}-fproxy-log-config
200             mountPath: /opt/app/fproxy/config/logback-spring.xml
201             subPath: logback-spring.xml
202           - name: {{ include "common.fullname" . }}-fproxy-auth-config
203             mountPath: /opt/app/fproxy/config/auth/tomcat_keystore
204             subPath: tomcat_keystore
205           - name: {{ include "common.fullname" . }}-fproxy-auth-config
206             mountPath: /opt/app/fproxy/config/auth/client-cert.p12
207             subPath: client-cert.p12
208           ports:
209           - containerPort: {{ .Values.global.fproxy.port }}
210     {{ end }}      
211
212       volumes:
213         - name: localtime
214           hostPath:
215             path: /etc/localtime
216         - name: {{ include "common.fullname" . }}-config
217           configMap:
218             name: {{ include "common.fullname" . }}
219             items:
220             - key: champ-api.properties
221               path: champ-api.properties
222         - name: {{ include "common.fullname" . }}-secrets
223           secret:
224             secretName: {{ include "common.fullname" . }}-champ
225         - name: {{ include "common.fullname" . }}-dynamic-config
226           configMap:
227             name: {{ include "common.fullname" . }}-dynamic
228             items:
229             - key: champ-beans.xml
230               path: champ-beans.xml
231         - name: {{ include "common.fullname" . }}-logs
232           emptyDir: {}
233         - name: {{ include "common.fullname" . }}-logback-config
234           configMap:
235             name: {{ include "common.fullname" . }}-log-configmap
236             items:
237             - key: logback.xml
238               path: logback.xml
239         - name: filebeat-conf
240           configMap:
241             name: aai-filebeat
242         - name: aai-filebeat
243           emptyDir: {}
244     {{ if .Values.global.installSidecarSecurity }}
245         - name: {{ include "common.fullname" . }}-rproxy-config
246           configMap:
247             name: {{ include "common.fullname" . }}-rproxy-config
248         - name: {{ include "common.fullname" . }}-rproxy-log-config
249           configMap:
250             name: {{ include "common.fullname" . }}-rproxy-log-config
251         - name: {{ include "common.fullname" . }}-rproxy-auth-config
252           secret:
253             secretName: {{ include "common.fullname" . }}-rproxy-auth-config
254         - name: {{ include "common.fullname" . }}-rproxy-security-config
255           secret:
256             secretName: {{ include "common.fullname" . }}-rproxy-security-config
257         - name: {{ include "common.fullname" . }}-fproxy-config
258           configMap:
259             name: {{ include "common.fullname" . }}-fproxy-config
260         - name: {{ include "common.fullname" . }}-fproxy-log-config
261           configMap:
262             name: {{ include "common.fullname" . }}-fproxy-log-config
263         - name: {{ include "common.fullname" . }}-fproxy-auth-config
264           secret:
265             secretName: {{ include "common.fullname" . }}-fproxy-auth-config
266     {{ end }}
267       imagePullSecrets:
268       - name: "{{ include "common.namespace" . }}-docker-registry-key"