[DCAEMOD] Uses new tpls for repos / images
[oom.git] / kubernetes / oof / components / oof-cmso / components / oof-cmso-service / templates / deployment.yaml
1 {{/*
2 # Copyright (c) 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         - {{ .Values.config.db.container }}
45         env:
46         - name: NAMESPACE
47           valueFrom:
48             fieldRef:
49               apiVersion: v1
50               fieldPath: metadata.namespace
51         image: "{{ include "common.repository" . }}/{{ .Values.global.readinessImage }}"
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 "common.repository" . }}/{{ .Values.global.readinessImage }}"
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: "{{ .Values.global.busyBoxRepository }}/{{ .Values.global.busyBoxImage }}"
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 "common.repository" . }}/{{ .Values.dbinit.image }}"
77         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
78         env:
79         - name: DB_HOST
80           value: {{ .Values.config.db.host }}.{{.Release.Namespace}}
81         - name: DB_PORT
82           value: {{ .Values.config.db.port | 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       # side car containers
98       - name: filebeat-onap
99         image: "{{ .Values.global.loggingRepository }}/{{ .Values.global.loggingImage }}"
100         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
101         volumeMounts:
102         - mountPath: /usr/share/filebeat/filebeat.yml
103           subPath: filebeat.yml
104           name: filebeat-conf
105         - mountPath: /var/log/onap
106           name: {{ include "common.fullname" . }}-logs
107         - mountPath: /usr/share/filebeat/data
108           name: {{ include "common.fullname" . }}-filebeat
109         resources:
110 {{ include "common.resources" . }}
111       - name: mso-simulator
112         image: "{{ include "common.repository" . }}/{{ .Values.robotimage }}"
113         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
114         volumeMounts:
115         - name: {{ include "common.fullname" . }}-config
116           mountPath: /share/etc/config
117         ports:
118         - containerPort: 5000
119         resources:
120 {{ include "common.resources" . }}
121       - name: {{ include "common.name" . }}
122         image: "{{ include "common.repository" . }}/{{ .Values.image }}"
123         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
124         env:
125         - name: DB_HOST
126           value: {{ .Values.config.db.host }}.{{.Release.Namespace}}
127         - name: DB_PORT
128           value: {{ .Values.config.db.port | quote}}
129         - name: DB_USERNAME
130           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cmso-db-user-secret" "key" "login") | indent 10}}
131         - name: DB_SCHEMA
132           value: {{ .Values.config.db.mysqlDatabase }}
133         - name: DB_PASSWORD
134           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cmso-db-user-secret" "key" "password") | indent 10}}
135         - name: JAVA_TRUSTSTORE
136           value: /share/etc/osaaf/local/{{ .Values.global.truststoreFile }}
137         - name: SSL_KEYSTORE
138           value: /share/etc/osaaf/local/{{ .Values.global.keystoreFile }}
139         - name: JAVA_TRUSTSTORE_PASSWORD
140           value: {{ .Values.global.truststorePassword }}
141         - name: AUTHENTICATION
142           value: {{ .Values.global.authentication }}
143         command:
144         - /bin/sh
145         args:
146         - "-c"
147         - |
148           export SSL_KEYSTORE_PASSWORD=$(cat /share/etc/osaaf/local/.pass)
149           ./startService.sh
150         ports:
151         - containerPort: {{ .Values.service.internalPort }}
152         # disable liveness probe when breakpoints set in debugger
153         # so K8s doesn't restart unresponsive container
154         {{- if eq .Values.liveness.enabled true }}
155         livenessProbe:
156           tcpSocket:
157             port: {{ .Values.service.internalPort }}
158           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
159           periodSeconds: {{ .Values.liveness.periodSeconds }}
160         {{ end -}}
161         readinessProbe:
162           tcpSocket:
163             port: {{ .Values.service.internalPort }}
164           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
165           periodSeconds: {{ .Values.readiness.periodSeconds }}
166         volumeMounts:
167 {{ include "common.certInitializer.volumeMount" . | indent 8 }}
168         - name: {{ include "common.fullname" . }}-logs
169           mountPath: /share/logs
170         - name: {{ include "common.fullname" . }}-logs
171           mountPath: /share/debug-logs
172         - name: {{ include "common.fullname" . }}-config
173           mountPath: /share/etc/config
174         - name: {{ include "common.fullname" . }}-certs
175           mountPath: /share/etc/certs
176         - name: {{ include "common.fullname" . }}-certs
177           mountPath: /opt/app/cmso/src/main/resources/aaf
178         resources:
179 {{ include "common.resources" . | indent 12 }}
180         {{- if .Values.nodeSelector }}
181         nodeSelector:
182 {{ toYaml .Values.nodeSelector | indent 10 }}
183         {{- end -}}
184         {{- if .Values.affinity }}
185         affinity:
186 {{ toYaml .Values.affinity | indent 10 }}
187         {{- end }}
188       volumes:
189         {{ include "common.certInitializer.volumes" . | nindent 8 }}
190         - name: {{ include "common.fullname" . }}-config
191           configMap:
192             name: {{ include "common.fullname" . }}
193             items:
194             - key: logback.xml
195               path: logback.xml
196             - key: cmso.properties
197               path: cmso.properties
198             - key: cadi.properties
199               path: cadi.properties
200             - key: optimizer.properties
201               path: optimizer.properties
202             - key: ticketmgt.properties
203               path: ticketmgt.properties
204             - key: liquibase.properties
205               path: liquibase.properties
206         - name:  {{ include "common.fullname" . }}-logs
207           emptyDir: {}
208         - name: {{ include "common.fullname" . }}-filebeat
209           emptyDir: {}
210         - name: filebeat-conf
211           configMap:
212             name: {{ include "common.release" . }}-cmso-filebeat-configmap
213         - name: {{ include "common.fullname" . }}-certs
214           secret:
215             secretName: {{ include "common.release" . }}-{{ .Values.global.commonConfigPrefix }}-certs
216       imagePullSecrets:
217       - name: "{{ include "common.namespace" . }}-docker-registry-key"