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