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