[GENERAL] Use readiness container v3.0.1
[oom.git] / kubernetes / oof / charts / oof-cmso / charts / oof-cmso-optimizer / templates / deployment.yaml
1 # Copyright © 2018 AT&T
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:
37       - command:
38         - /app/ready.py
39         args:
40         - --container-name
41         - {{ .Values.config.db.container }}
42         env:
43         - name: NAMESPACE
44           valueFrom:
45             fieldRef:
46               apiVersion: v1
47               fieldPath: metadata.namespace
48         image: "{{ include "common.repository" . }}/{{ .Values.global.readinessImage }}"
49         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
50         name: {{ include "common.name" . }}-readiness
51       - name: {{ include "common.name" . }}-chown
52         command: ["/bin/sh", "-c", "chown -Rf 1000:1000 /share/"]
53         image: "{{ .Values.global.busyBoxRepository }}/{{ .Values.global.busyBoxImage }}"
54         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
55         volumeMounts:
56         - name: {{ include "common.fullname" . }}-logs
57           mountPath: /share/logs
58       - name: db-init
59         image: "{{ include "common.repository" . }}/{{ .Values.dbinit.image }}"
60         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
61         env:
62         - name: DB_HOST
63           value: {{ .Values.config.db.host }}.{{.Release.Namespace}}
64         - name: DB_PORT
65           value: {{ .Values.config.db.port | quote}}
66         - name: DB_USERNAME
67           value: {{ .Values.config.db.root }}
68         - name: DB_SCHEMA
69           value: {{ .Values.config.db.mysqlDatabase }}
70         - name: DB_PASSWORD
71           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cmso-db-root-password" "key" "password") | indent 10}}
72         terminationMessagePolicy: File
73         volumeMounts:
74         - name: {{ include "common.fullname" . }}-config
75           mountPath: /share/etc/config
76         - name: {{ include "common.fullname" . }}-logs
77           mountPath: /share/logs
78       containers:
79       - name: {{ include "common.name" . }}
80         image: "{{ include "common.repository" . }}/{{ .Values.image }}"
81         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
82         env:
83         - name: DB_HOST
84           value: {{ .Values.config.db.host }}.{{.Release.Namespace}}
85         - name: DB_PORT
86           value: {{ .Values.config.db.port | quote}}
87         - name: DB_USERNAME
88           value: {{ .Values.config.db.root }}
89         - name: DB_SCHEMA
90           value: {{ .Values.config.db.mysqlDatabase }}
91         - name: DB_PASSWORD
92           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cmso-db-root-password" "key" "password") | indent 10}}
93         - name: JAVA_TRUSTSTORE
94           value: /share/etc/certs/{{ .Values.global.truststoreFile }}
95         - name: SSL_KEYSTORE
96           value: /share/etc/certs/{{ .Values.global.keystoreFile }}
97         - name: JAVA_TRUSTSTORE_PASSWORD
98           value: {{ .Values.global.truststorePassword }}
99         - name: SSL_KEYSTORE_PASSWORD
100           value: {{ .Values.global.keystorePassword }}
101         - name: AUTHENTICATION
102           value: {{ .Values.global.authentication }}
103         ports:
104         - containerPort: {{ .Values.service.internalPort }}
105         # disable liveness probe when breakpoints set in debugger
106         # so K8s doesn't restart unresponsive container
107         {{- if eq .Values.liveness.enabled true }}
108         livenessProbe:
109           tcpSocket:
110             port: {{ .Values.service.internalPort }}
111           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
112           periodSeconds: {{ .Values.liveness.periodSeconds }}
113         {{ end -}}
114         readinessProbe:
115           tcpSocket:
116             port: {{ .Values.service.internalPort }}
117           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
118           periodSeconds: {{ .Values.readiness.periodSeconds }}
119         volumeMounts:
120         - name: {{ include "common.fullname" . }}-logs
121           mountPath: /share/logs
122         - name: {{ include "common.fullname" . }}-logs
123           mountPath: /share/debug-logs
124         - name: {{ include "common.fullname" . }}-config
125           mountPath: /share/etc/config
126         - name: {{ include "common.fullname" . }}-certs
127           mountPath: /share/etc/certs
128         - name: {{ include "common.fullname" . }}-certs
129           mountPath: /opt/app/cmso/src/main/resources/aaf
130         resources:
131 {{ include "common.resources" . | indent 12 }}
132         {{- if .Values.nodeSelector }}
133         nodeSelector:
134 {{ toYaml .Values.nodeSelector | indent 10 }}
135         {{- end -}}
136         {{- if .Values.affinity }}
137         affinity:
138 {{ toYaml .Values.affinity | indent 10 }}
139         {{- end }}
140       volumes:
141         - name: {{ include "common.fullname" . }}-config
142           configMap:
143             name: {{ include "common.fullname" . }}
144             items:
145             - key: logback.xml
146               path: logback.xml
147             - key: cadi.properties
148               path: cadi.properties
149             - key: optimizer.properties
150               path: optimizer.properties
151             - key: liquibase.properties
152               path: liquibase.properties
153         - name:  {{ include "common.fullname" . }}-logs
154           emptyDir: {}
155         - name: {{ include "common.fullname" . }}-certs
156           secret:
157             secretName: {{ include "common.release" . }}-{{ .Values.global.commonConfigPrefix }}-certs
158       imagePullSecrets:
159       - name: "{{ include "common.namespace" . }}-docker-registry-key"