[GENERAL] Use readiness container v3.0.1
[oom.git] / kubernetes / oof / charts / oof-cmso / charts / oof-cmso-service / templates / deployment.yaml
1 # Copyright (c) 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       # side car containers
80       - name: filebeat-onap
81         image: "{{ .Values.global.loggingRepository }}/{{ .Values.global.loggingImage }}"
82         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
83         volumeMounts:
84         - mountPath: /usr/share/filebeat/filebeat.yml
85           subPath: filebeat.yml
86           name: filebeat-conf
87         - mountPath: /var/log/onap
88           name: {{ include "common.fullname" . }}-logs
89         - mountPath: /usr/share/filebeat/data
90           name: {{ include "common.fullname" . }}-filebeat
91         resources:
92 {{ include "common.resources" . }}
93       - name: mso-simulator
94         image: "{{ include "common.repository" . }}/{{ .Values.robotimage }}"
95         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
96         volumeMounts:
97         - name: {{ include "common.fullname" . }}-config
98           mountPath: /share/etc/config
99         ports:
100         - containerPort: 5000
101         resources:
102 {{ include "common.resources" . }}
103       - name: {{ include "common.name" . }}
104         image: "{{ include "common.repository" . }}/{{ .Values.image }}"
105         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
106         env:
107         - name: DB_HOST
108           value: {{ .Values.config.db.host }}.{{.Release.Namespace}}
109         - name: DB_PORT
110           value: {{ .Values.config.db.port | quote}}
111         - name: DB_USERNAME
112           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cmso-db-user-secret" "key" "login") | indent 10}}
113         - name: DB_SCHEMA
114           value: {{ .Values.config.db.mysqlDatabase }}
115         - name: DB_PASSWORD
116           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cmso-db-user-secret" "key" "password") | indent 10}}
117         - name: JAVA_TRUSTSTORE
118           value: /share/etc/certs/{{ .Values.global.truststoreFile }}
119         - name: SSL_KEYSTORE
120           value: /share/etc/certs/{{ .Values.global.keystoreFile }}
121         - name: JAVA_TRUSTSTORE_PASSWORD
122           value: {{ .Values.global.truststorePassword }}
123         - name: SSL_KEYSTORE_PASSWORD
124           value: {{ .Values.global.keystorePassword }}
125         - name: AUTHENTICATION
126           value: {{ .Values.global.authentication }}
127         ports:
128         - containerPort: {{ .Values.service.internalPort }}
129         # disable liveness probe when breakpoints set in debugger
130         # so K8s doesn't restart unresponsive container
131         {{- if eq .Values.liveness.enabled true }}
132         livenessProbe:
133           tcpSocket:
134             port: {{ .Values.service.internalPort }}
135           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
136           periodSeconds: {{ .Values.liveness.periodSeconds }}
137         {{ end -}}
138         readinessProbe:
139           tcpSocket:
140             port: {{ .Values.service.internalPort }}
141           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
142           periodSeconds: {{ .Values.readiness.periodSeconds }}
143         volumeMounts:
144         - name: {{ include "common.fullname" . }}-logs
145           mountPath: /share/logs
146         - name: {{ include "common.fullname" . }}-logs
147           mountPath: /share/debug-logs
148         - name: {{ include "common.fullname" . }}-config
149           mountPath: /share/etc/config
150         - name: {{ include "common.fullname" . }}-certs
151           mountPath: /share/etc/certs
152         - name: {{ include "common.fullname" . }}-certs
153           mountPath: /opt/app/cmso/src/main/resources/aaf
154         resources:
155 {{ include "common.resources" . | indent 12 }}
156         {{- if .Values.nodeSelector }}
157         nodeSelector:
158 {{ toYaml .Values.nodeSelector | indent 10 }}
159         {{- end -}}
160         {{- if .Values.affinity }}
161         affinity:
162 {{ toYaml .Values.affinity | indent 10 }}
163         {{- end }}
164       volumes:
165         - name: {{ include "common.fullname" . }}-config
166           configMap:
167             name: {{ include "common.fullname" . }}
168             items:
169             - key: logback.xml
170               path: logback.xml
171             - key: cmso.properties
172               path: cmso.properties
173             - key: cadi.properties
174               path: cadi.properties
175             - key: optimizer.properties
176               path: optimizer.properties
177             - key: ticketmgt.properties
178               path: ticketmgt.properties
179             - key: liquibase.properties
180               path: liquibase.properties
181         - name:  {{ include "common.fullname" . }}-logs
182           emptyDir: {}
183         - name: {{ include "common.fullname" . }}-filebeat
184           emptyDir: {}
185         - name: filebeat-conf
186           configMap:
187             name: {{ include "common.release" . }}-cmso-filebeat-configmap
188         - name: {{ include "common.fullname" . }}-certs
189           secret:
190             secretName: {{ include "common.release" . }}-{{ .Values.global.commonConfigPrefix }}-certs
191       imagePullSecrets:
192       - name: "{{ include "common.namespace" . }}-docker-registry-key"