Merge "Migrate oom docs"
[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: db-init
49         image: "{{ include "common.repository" . }}/{{ .Values.dbinit.image }}"
50         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
51         env:
52         - name: DB_HOST
53           value: {{ .Values.config.db.host }}.{{.Release.Namespace}}
54         - name: DB_PORT
55           value: {{ .Values.config.db.port | quote}}
56         - name: DB_USERNAME
57           value: {{ .Values.config.db.root }}
58         - name: DB_SCHEMA
59           value: {{ .Values.config.db.mysqlDatabase }}
60         - name: DB_PASSWORD
61           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cmso-db-root-password" "key" "password") | indent 10}}
62         terminationMessagePolicy: File
63         volumeMounts:
64         - name: {{ include "common.fullname" . }}-config
65           mountPath: /share/etc/config
66         - name: {{ include "common.fullname" . }}-logs
67           mountPath: /share/logs
68       containers:
69       - name: {{ include "common.name" . }}
70         image: "{{ include "common.repository" . }}/{{ .Values.image }}"
71         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
72         env:
73         - name: DB_HOST
74           value: {{ .Values.config.db.host }}.{{.Release.Namespace}}
75         - name: DB_PORT
76           value: {{ .Values.config.db.port | quote}}
77         - name: DB_USERNAME
78           value: {{ .Values.config.db.root }}
79         - name: DB_SCHEMA
80           value: {{ .Values.config.db.mysqlDatabase }}
81         - name: DB_PASSWORD
82           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cmso-db-root-password" "key" "password") | indent 10}}
83         - name: JAVA_TRUSTSTORE
84           value: /share/etc/certs/{{ .Values.global.truststoreFile }}
85         - name: SSL_KEYSTORE
86           value: /share/etc/certs/{{ .Values.global.keystoreFile }}
87         - name: JAVA_TRUSTSTORE_PASSWORD
88           value: {{ .Values.global.truststorePassword }}
89         - name: SSL_KEYSTORE_PASSWORD
90           value: {{ .Values.global.keystorePassword }}
91         - name: AUTHENTICATION
92           value: {{ .Values.global.authentication }}
93         ports:
94         - containerPort: {{ .Values.service.internalPort }}
95         # disable liveness probe when breakpoints set in debugger
96         # so K8s doesn't restart unresponsive container
97         {{- if eq .Values.liveness.enabled true }}
98         livenessProbe:
99           tcpSocket:
100             port: {{ .Values.service.internalPort }}
101           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
102           periodSeconds: {{ .Values.liveness.periodSeconds }}
103         {{ end -}}
104         readinessProbe:
105           tcpSocket:
106             port: {{ .Values.service.internalPort }}
107           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
108           periodSeconds: {{ .Values.readiness.periodSeconds }}
109         volumeMounts:
110         - name: {{ include "common.fullname" . }}-logs
111           mountPath: /share/logs
112         - name: {{ include "common.fullname" . }}-logs
113           mountPath: /share/debug-logs
114         - name: {{ include "common.fullname" . }}-config
115           mountPath: /share/etc/config
116         - name: {{ include "common.fullname" . }}-certs
117           mountPath: /share/etc/certs
118         - name: {{ include "common.fullname" . }}-certs
119           mountPath: /opt/app/cmso/src/main/resources/aaf
120         resources:
121 {{ include "common.resources" . | indent 12 }}
122         {{- if .Values.nodeSelector }}
123         nodeSelector:
124 {{ toYaml .Values.nodeSelector | indent 10 }}
125         {{- end -}}
126         {{- if .Values.affinity }}
127         affinity:
128 {{ toYaml .Values.affinity | indent 10 }}
129         {{- end }}
130       volumes:
131         - name: {{ include "common.fullname" . }}-config
132           configMap:
133             name: {{ include "common.fullname" . }}
134             items:
135             - key: logback.xml
136               path: logback.xml
137             - key: cadi.properties
138               path: cadi.properties
139             - key: optimizer.properties
140               path: optimizer.properties
141             - key: liquibase.properties
142               path: liquibase.properties
143         - name:  {{ include "common.fullname" . }}-logs
144           emptyDir: {}
145         - name: {{ include "common.fullname" . }}-certs
146           secret:
147             secretName: {{ include "common.release" . }}-{{ .Values.global.commonConfigPrefix }}-certs
148       imagePullSecrets:
149       - name: "{{ include "common.namespace" . }}-docker-registry-key"