8a7c43f0b95096b58290428c782aa9ded2b6f7be
[oom.git] / kubernetes / aai / components / aai-schema-service / templates / deployment.yaml
1 {{/*
2 # Copyright © 2017 Amdocs, Bell Canada
3 # Modifications Copyright © 2018 AT&T
4 # Modifications Copyright © 2020 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   replicas: {{ .Values.replicaCount }}
31   strategy:
32     type: {{ .Values.updateStrategy.type }}
33     {{- if (eq "RollingUpdate" .Values.updateStrategy.type) }}
34     rollingUpdate:
35       maxUnavailable: {{ .Values.updateStrategy.maxUnavailable }}
36       maxSurge: {{ .Values.updateStrategy.maxSurge }}
37     {{- end }}
38   selector:
39     matchLabels:
40       app: {{ include "common.name" . }}
41   template:
42     metadata:
43       labels:
44         app: {{ include "common.name" . }}
45         release: {{ include "common.release" . }}
46       name: {{ include "common.name" . }}
47       annotations:
48         checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
49     spec:
50       {{- if .Values.global.aafEnabled }}
51       initContainers: {{ include "common.certInitializer.initContainer" . | nindent 6 }}
52       - command:
53         - sh
54         args:
55         - -c
56         - |
57           echo "*** retrieve Truststore and Keystore password"
58           export $(cat {{ .Values.certInitializer.appMountPath }}/local/mycreds.prop | xargs -0)
59           echo "*** obfuscate them "
60           export KEYSTORE_PLAIN_PASSWORD=${KEYSTORE_PLAIN_PASSWORD}
61           export TRUSTSTORE_PLAIN_PASSWORD=${TRUSTSTORE_PLAIN_PASSWORD}
62           export JETTY_UTIL_JAR=$(find /usr/local/jetty/lib/ -regextype sed -regex ".*jetty-util-[0-9].*.jar")
63           export KEYSTORE_PASSWORD=`java -cp ${JETTY_UTIL_JAR} org.eclipse.jetty.util.security.Password ${KEYSTORE_PLAIN_PASSWORD} 2>&1 | grep "OBF:"`
64           export TRUSTSTORE_PASSWORD=`java -cp ${JETTY_UTIL_JAR} org.eclipse.jetty.util.security.Password ${TRUSTSTORE_PLAIN_PASSWORD} 2>&1 | grep "OBF:"`
65           echo "KEYSTORE_PASSWORD=${KEYSTORE_PASSWORD}" >> {{ .Values.certInitializer.appMountPath }}/local/mycreds.prop
66           echo "TRUSTSTORE_PASSWORD=${TRUSTSTORE_PASSWORD}" >> {{ .Values.certInitializer.appMountPath }}/local/mycreds.prop
67         image: {{ include "repositoryGenerator.image.jetty" . }}
68         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
69         name: {{ include "common.name" . }}-obfuscate
70         volumeMounts: {{ include "common.certInitializer.volumeMount" . | nindent 8 }}
71         securityContext:
72           runAsUser: {{ .Values.securityContext.user_id }}
73       {{- end }}
74       containers:
75       - name: {{ include "common.name" . }}
76         image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
77         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
78         {{- if .Values.global.aafEnabled }}
79         command:
80         - sh
81         args:
82         - -c
83         - |
84           echo "*** retrieve Truststore and Keystore password"
85           export $(cat {{ .Values.certInitializer.credsPath }}/mycreds.prop | xargs -0)
86           echo "*** actual launch of AAI Schema Service"
87           /bin/bash /opt/app/aai-schema-service/docker-entrypoint.sh
88         {{- end }}
89         env:
90         - name: LOCAL_USER_ID
91           value: {{ .Values.securityContext.user_id | quote }}
92         - name: LOCAL_GROUP_ID
93           value: {{ .Values.securityContext.group_id | quote }}
94         volumeMounts: {{ include "common.certInitializer.volumeMount" . | nindent 8 }}
95         - mountPath: /etc/localtime
96           name: localtime
97           readOnly: true
98         - mountPath: /opt/app/aai-schema-service/resources/etc/appprops/aaiconfig.properties
99           name: aaiconfig-conf
100           subPath: aaiconfig.properties
101         - mountPath: /opt/aai/logroot/AAI-SS
102           name: logs
103         - mountPath: /opt/app/aai-schema-service/resources/logback.xml
104           name: log-conf
105           subPath: logback.xml
106         - mountPath: /opt/app/aai-schema-service/resources/localhost-access-logback.xml
107           name: localhost-access-log-conf
108           subPath: localhost-access-logback.xml
109         - mountPath: /opt/app/aai-schema-service/resources/etc/auth/realm.properties
110           name: realm-conf
111           subPath: realm.properties
112         - mountPath: /opt/app/aai-schema-service/resources/application.properties
113           name: springapp-conf
114           subPath: application.properties
115         ports:
116         - containerPort: {{ .Values.service.internalPort }}
117         - containerPort: {{ .Values.service.internalPort2 }}
118         # disable liveness probe when breakpoints set in debugger
119         # so K8s doesn't restart unresponsive container
120         {{ if .Values.liveness.enabled }}
121         livenessProbe:
122           tcpSocket:
123             port: {{ .Values.service.internalPort }}
124           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
125           periodSeconds: {{ .Values.liveness.periodSeconds }}
126         {{ end }}
127         readinessProbe:
128           tcpSocket:
129             port: {{ .Values.service.internalPort }}
130           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
131           periodSeconds: {{ .Values.readiness.periodSeconds }}
132         resources:
133 {{ include "common.resources" . | indent 12 }}
134       {{- if .Values.nodeSelector }}
135       nodeSelector:
136 {{ toYaml .Values.nodeSelector | indent 8 }}
137       {{- end -}}
138       {{- if .Values.affinity }}
139       affinity:
140 {{ toYaml .Values.affinity | indent 8 }}
141       {{- end }}
142
143       # side car containers
144       {{ include "common.log.sidecar" . | nindent 6 }}
145       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
146       volumes: {{ include "common.certInitializer.volumes" . | nindent 6 }}
147       - name: aai-common-aai-auth-mount
148         secret:
149           secretName: aai-common-aai-auth
150       - name: localtime
151         hostPath:
152           path: /etc/localtime
153       - name: logs
154         emptyDir: {}
155       {{ include "common.log.volumes" (dict "dot" . "configMapNamePrefix" (tpl .Values.logConfigMapNamePrefix .)) | nindent 6 }}
156       - name: log-conf
157         configMap:
158           name: {{ include "common.fullname" . }}-log
159       - name: localhost-access-log-conf
160         configMap:
161           name: {{ include "common.fullname" . }}-localhost-access-log
162       - name: springapp-conf
163         configMap:
164           name: {{ include "common.fullname" . }}-springapp
165       - name: aaiconfig-conf
166         configMap:
167           name: {{ include "common.fullname" . }}-aaiconfig
168       - name: realm-conf
169         configMap:
170           name: {{ include "common.fullname" . }}-realm
171       restartPolicy: {{ .Values.restartPolicy }}
172       imagePullSecrets:
173       - name: "{{ include "common.namespace" . }}-docker-registry-key"