Merge "[COMMON] Add missing .helmignore files and "components/" entries"
[oom.git] / kubernetes / oof / components / oof-cmso / components / oof-cmso-optimizer / templates / deployment.yaml
1 {{/*
2 # Copyright © 2018 AT&T
3 # Copyright (C) 2020 Wipro Limited.
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:
40       - command:
41         - /app/ready.py
42         args:
43         - --container-name
44         - {{ include "common.mariadbService" . }}
45         env:
46         - name: NAMESPACE
47           valueFrom:
48             fieldRef:
49               apiVersion: v1
50               fieldPath: metadata.namespace
51         image: {{ include "repositoryGenerator.image.readiness" . }}
52         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
53         name: {{ include "common.name" . }}-readiness
54       - name: {{ include "common.name" . }}-db-config-readiness
55         command:
56         - /app/ready.py
57         args:
58         - -j
59         - "{{ include "common.release" . }}-cmso-db-config-config-job"
60         env:
61         - name: NAMESPACE
62           valueFrom:
63             fieldRef:
64               apiVersion: v1
65               fieldPath: metadata.namespace
66         image: {{ include "repositoryGenerator.image.readiness" . }}
67         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
68       - name: {{ include "common.name" . }}-chown
69         command: ["/bin/sh", "-c", "chown -Rf 1000:1000 /share/"]
70         image: {{ include "repositoryGenerator.image.busybox" . }}
71         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
72         volumeMounts:
73         - name: {{ include "common.fullname" . }}-logs
74           mountPath: /share/logs
75       - name: db-init
76         image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.dbinit.image }}
77         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
78         env:
79         - name: DB_HOST
80           value: {{ include "common.mariadbService" . }}.{{.Release.Namespace}}
81         - name: DB_PORT
82           value: {{ include "common.mariadbPort" . | quote}}
83         - name: DB_USERNAME
84           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cmso-db-user-secret" "key" "login") | indent 10}}
85         - name: DB_SCHEMA
86           value: {{ .Values.config.db.mysqlDatabase }}
87         - name: DB_PASSWORD
88           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cmso-db-user-secret" "key" "password") | indent 10}}
89         terminationMessagePolicy: File
90         volumeMounts:
91         - name: {{ include "common.fullname" . }}-config
92           mountPath: /share/etc/config
93         - name: {{ include "common.fullname" . }}-logs
94           mountPath: /share/logs
95 {{ include "common.certInitializer.initContainer" . | indent 6 }}
96       containers:
97       - name: {{ include "common.name" . }}
98         image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
99         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
100         env:
101         - name: DB_HOST
102           value: {{ include "common.mariadbService" . }}.{{.Release.Namespace}}
103         - name: DB_PORT
104           value: {{ include "common.mariadbPort" . | quote}}
105         - name: DB_USERNAME
106           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cmso-db-user-secret" "key" "login") | indent 10}}
107         - name: DB_SCHEMA
108           value: {{ .Values.config.db.mysqlDatabase }}
109         - name: DB_PASSWORD
110           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cmso-db-user-secret" "key" "password") | indent 10}}
111         - name: JAVA_TRUSTSTORE
112           value: /share/etc/osaaf/local/{{ .Values.global.truststoreFile }}
113         - name: SSL_KEYSTORE
114           value: /share/etc/osaaf/local/{{ .Values.global.keystoreFile }}
115         - name: JAVA_TRUSTSTORE_PASSWORD
116           value: {{ .Values.global.truststorePassword }}
117         - name: AUTHENTICATION
118           value: {{ .Values.global.authentication }}
119         - name: AAF_USER
120           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cmso-aaf-creds" "key" "login") | indent 10}}
121         - name: AAF_PASSWORD
122           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cmso-aaf-creds" "key" "password") | indent 10}}
123         - name: VM_ARGS
124           value: "-Dcom.att.eelf.logging.file=logback.xml -Dcom.att.eelf.logging.path=/share/etc/config"
125         command:
126         - /bin/sh
127         args:
128         - "-c"
129         - |
130           export SSL_KEYSTORE_PASSWORD=$(cat /share/etc/osaaf/local/.pass)
131           ./startService.sh
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         volumeMounts:
149 {{ include "common.certInitializer.volumeMount" . | indent 8 }}
150         - name: {{ include "common.fullname" . }}-logs
151           mountPath: /share/logs
152         - name: {{ include "common.fullname" . }}-logs
153           mountPath: /share/debug-logs
154         - name: {{ include "common.fullname" . }}-config
155           mountPath: /share/etc/config
156         - name: {{ include "common.fullname" . }}-certs
157           mountPath: /share/etc/certs
158         - name: {{ include "common.fullname" . }}-certs
159           mountPath: /opt/app/cmso/src/main/resources/aaf
160         resources:
161 {{ include "common.resources" . | indent 12 }}
162         {{- if .Values.nodeSelector }}
163         nodeSelector:
164 {{ toYaml .Values.nodeSelector | indent 10 }}
165         {{- end -}}
166         {{- if .Values.affinity }}
167         affinity:
168 {{ toYaml .Values.affinity | indent 10 }}
169         {{- end }}
170       volumes:
171         {{ include "common.certInitializer.volumes" . | nindent 8 }}
172         - name: {{ include "common.fullname" . }}-config
173           configMap:
174             name: {{ include "common.fullname" . }}
175             items:
176             - key: logback.xml
177               path: logback.xml
178             - key: cadi.properties
179               path: cadi.properties
180             - key: optimizer.properties
181               path: optimizer.properties
182             - key: liquibase.properties
183               path: liquibase.properties
184         - name:  {{ include "common.fullname" . }}-logs
185           emptyDir: {}
186         - name: {{ include "common.fullname" . }}-certs
187           secret:
188             secretName: {{ include "common.release" . }}-{{ .Values.global.commonConfigPrefix }}-certs
189       imagePullSecrets:
190       - name: "{{ include "common.namespace" . }}-docker-registry-key"