[CONSUL] Add limits to consul chart.
[oom.git] / kubernetes / oof / components / oof-cmso / components / oof-cmso-service / templates / deployment.yaml
1 # Copyright (c) 2018 AT&T
2 # Copyright (C) 2020 Wipro Limited.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #       http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 apiVersion: apps/v1
17 kind: Deployment
18 metadata:
19   name: {{ include "common.fullname" . }}
20   namespace: {{ include "common.namespace" . }}
21   labels:
22     app: {{ include "common.name" . }}
23     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
24     release: {{ include "common.release" . }}
25     heritage: {{ .Release.Service }}
26 spec:
27   selector:
28     matchLabels:
29       app: {{ include "common.name" . }}
30   replicas: {{ .Values.replicaCount }}
31   template:
32     metadata:
33       labels:
34         app: {{ include "common.name" . }}
35         release: {{ include "common.release" . }}
36     spec:
37       initContainers:
38       - command:
39         - /app/ready.py
40         args:
41         - --container-name
42         - {{ .Values.config.db.container }}
43         env:
44         - name: NAMESPACE
45           valueFrom:
46             fieldRef:
47               apiVersion: v1
48               fieldPath: metadata.namespace
49         image: "{{ include "common.repository" . }}/{{ .Values.global.readinessImage }}"
50         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
51         name: {{ include "common.name" . }}-readiness
52       - name: {{ include "common.name" . }}-db-config-readiness
53         command:
54         - /app/ready.py
55         args:
56         - -j
57         - "{{ include "common.release" . }}-cmso-db-config-config-job"
58         env:
59         - name: NAMESPACE
60           valueFrom:
61             fieldRef:
62               apiVersion: v1
63               fieldPath: metadata.namespace
64         image: "{{ include "common.repository" . }}/{{ .Values.global.readinessImage }}"
65         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
66       - name: {{ include "common.name" . }}-chown
67         command: ["/bin/sh", "-c", "chown -Rf 1000:1000 /share/"]
68         image: "{{ .Values.global.busyBoxRepository }}/{{ .Values.global.busyBoxImage }}"
69         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
70         volumeMounts:
71         - name: {{ include "common.fullname" . }}-logs
72           mountPath: /share/logs
73       - name: db-init
74         image: "{{ include "common.repository" . }}/{{ .Values.dbinit.image }}"
75         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
76         env:
77         - name: DB_HOST
78           value: {{ .Values.config.db.host }}.{{.Release.Namespace}}
79         - name: DB_PORT
80           value: {{ .Values.config.db.port | quote}}
81         - name: DB_USERNAME
82           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cmso-db-user-secret" "key" "login") | indent 10}}
83         - name: DB_SCHEMA
84           value: {{ .Values.config.db.mysqlDatabase }}
85         - name: DB_PASSWORD
86           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cmso-db-user-secret" "key" "password") | indent 10}}
87         terminationMessagePolicy: File
88         volumeMounts:
89         - name: {{ include "common.fullname" . }}-config
90           mountPath: /share/etc/config
91         - name: {{ include "common.fullname" . }}-logs
92           mountPath: /share/logs
93 {{ include "common.certInitializer.initContainer" . | indent 6 }}
94       containers:
95       # side car containers
96       - name: filebeat-onap
97         image: "{{ .Values.global.loggingRepository }}/{{ .Values.global.loggingImage }}"
98         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
99         volumeMounts:
100         - mountPath: /usr/share/filebeat/filebeat.yml
101           subPath: filebeat.yml
102           name: filebeat-conf
103         - mountPath: /var/log/onap
104           name: {{ include "common.fullname" . }}-logs
105         - mountPath: /usr/share/filebeat/data
106           name: {{ include "common.fullname" . }}-filebeat
107         resources:
108 {{ include "common.resources" . }}
109       - name: mso-simulator
110         image: "{{ include "common.repository" . }}/{{ .Values.robotimage }}"
111         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
112         volumeMounts:
113         - name: {{ include "common.fullname" . }}-config
114           mountPath: /share/etc/config
115         ports:
116         - containerPort: 5000
117         resources:
118 {{ include "common.resources" . }}
119       - name: {{ include "common.name" . }}
120         image: "{{ include "common.repository" . }}/{{ .Values.image }}"
121         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
122         env:
123         - name: DB_HOST
124           value: {{ .Values.config.db.host }}.{{.Release.Namespace}}
125         - name: DB_PORT
126           value: {{ .Values.config.db.port | quote}}
127         - name: DB_USERNAME
128           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cmso-db-user-secret" "key" "login") | indent 10}}
129         - name: DB_SCHEMA
130           value: {{ .Values.config.db.mysqlDatabase }}
131         - name: DB_PASSWORD
132           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cmso-db-user-secret" "key" "password") | indent 10}}
133         - name: JAVA_TRUSTSTORE
134           value: /share/etc/osaaf/local/{{ .Values.global.truststoreFile }}
135         - name: SSL_KEYSTORE
136           value: /share/etc/osaaf/local/{{ .Values.global.keystoreFile }}
137         - name: JAVA_TRUSTSTORE_PASSWORD
138           value: {{ .Values.global.truststorePassword }}
139         - name: AUTHENTICATION
140           value: {{ .Values.global.authentication }}
141         command:
142         - /bin/sh
143         args:
144         - "-c"
145         - |
146           export SSL_KEYSTORE_PASSWORD=$(cat /share/etc/osaaf/local/.pass)
147           ./startService.sh
148         ports:
149         - containerPort: {{ .Values.service.internalPort }}
150         # disable liveness probe when breakpoints set in debugger
151         # so K8s doesn't restart unresponsive container
152         {{- if eq .Values.liveness.enabled true }}
153         livenessProbe:
154           tcpSocket:
155             port: {{ .Values.service.internalPort }}
156           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
157           periodSeconds: {{ .Values.liveness.periodSeconds }}
158         {{ end -}}
159         readinessProbe:
160           tcpSocket:
161             port: {{ .Values.service.internalPort }}
162           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
163           periodSeconds: {{ .Values.readiness.periodSeconds }}
164         volumeMounts:
165 {{ include "common.certInitializer.volumeMount" . | indent 8 }}
166         - name: {{ include "common.fullname" . }}-logs
167           mountPath: /share/logs
168         - name: {{ include "common.fullname" . }}-logs
169           mountPath: /share/debug-logs
170         - name: {{ include "common.fullname" . }}-config
171           mountPath: /share/etc/config
172         - name: {{ include "common.fullname" . }}-certs
173           mountPath: /share/etc/certs
174         - name: {{ include "common.fullname" . }}-certs
175           mountPath: /opt/app/cmso/src/main/resources/aaf
176         resources:
177 {{ include "common.resources" . | indent 12 }}
178         {{- if .Values.nodeSelector }}
179         nodeSelector:
180 {{ toYaml .Values.nodeSelector | indent 10 }}
181         {{- end -}}
182         {{- if .Values.affinity }}
183         affinity:
184 {{ toYaml .Values.affinity | indent 10 }}
185         {{- end }}
186       volumes:
187         {{ include "common.certInitializer.volumes" . | nindent 8 }}
188         - name: {{ include "common.fullname" . }}-config
189           configMap:
190             name: {{ include "common.fullname" . }}
191             items:
192             - key: logback.xml
193               path: logback.xml
194             - key: cmso.properties
195               path: cmso.properties
196             - key: cadi.properties
197               path: cadi.properties
198             - key: optimizer.properties
199               path: optimizer.properties
200             - key: ticketmgt.properties
201               path: ticketmgt.properties
202             - key: liquibase.properties
203               path: liquibase.properties
204         - name:  {{ include "common.fullname" . }}-logs
205           emptyDir: {}
206         - name: {{ include "common.fullname" . }}-filebeat
207           emptyDir: {}
208         - name: filebeat-conf
209           configMap:
210             name: {{ include "common.release" . }}-cmso-filebeat-configmap
211         - name: {{ include "common.fullname" . }}-certs
212           secret:
213             secretName: {{ include "common.release" . }}-{{ .Values.global.commonConfigPrefix }}-certs
214       imagePullSecrets:
215       - name: "{{ include "common.namespace" . }}-docker-registry-key"