[CONSUL] Add limits to consul chart.
[oom.git] / kubernetes / oof / components / oof-cmso / components / oof-cmso-optimizer / templates / deployment.yaml
1 # Copyright © 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       - name: {{ include "common.name" . }}
96         image: "{{ include "common.repository" . }}/{{ .Values.image }}"
97         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
98         env:
99         - name: DB_HOST
100           value: {{ .Values.config.db.host }}.{{.Release.Namespace}}
101         - name: DB_PORT
102           value: {{ .Values.config.db.port | quote}}
103         - name: DB_USERNAME
104           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cmso-db-user-secret" "key" "login") | indent 10}}
105         - name: DB_SCHEMA
106           value: {{ .Values.config.db.mysqlDatabase }}
107         - name: DB_PASSWORD
108           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cmso-db-user-secret" "key" "password") | indent 10}}
109         - name: JAVA_TRUSTSTORE
110           value: /share/etc/osaaf/local/{{ .Values.global.truststoreFile }}
111         - name: SSL_KEYSTORE
112           value: /share/etc/osaaf/local/{{ .Values.global.keystoreFile }}
113         - name: JAVA_TRUSTSTORE_PASSWORD
114           value: {{ .Values.global.truststorePassword }}
115         - name: AUTHENTICATION
116           value: {{ .Values.global.authentication }}
117         command:
118         - /bin/sh
119         args:
120         - "-c"
121         - |
122           export SSL_KEYSTORE_PASSWORD=$(cat /share/etc/osaaf/local/.pass)
123           ./startService.sh
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 {{ include "common.certInitializer.volumeMount" . | indent 8 }}
142         - name: {{ include "common.fullname" . }}-logs
143           mountPath: /share/logs
144         - name: {{ include "common.fullname" . }}-logs
145           mountPath: /share/debug-logs
146         - name: {{ include "common.fullname" . }}-config
147           mountPath: /share/etc/config
148         - name: {{ include "common.fullname" . }}-certs
149           mountPath: /share/etc/certs
150         - name: {{ include "common.fullname" . }}-certs
151           mountPath: /opt/app/cmso/src/main/resources/aaf
152         resources:
153 {{ include "common.resources" . | indent 12 }}
154         {{- if .Values.nodeSelector }}
155         nodeSelector:
156 {{ toYaml .Values.nodeSelector | indent 10 }}
157         {{- end -}}
158         {{- if .Values.affinity }}
159         affinity:
160 {{ toYaml .Values.affinity | indent 10 }}
161         {{- end }}
162       volumes:
163         {{ include "common.certInitializer.volumes" . | nindent 8 }}
164         - name: {{ include "common.fullname" . }}-config
165           configMap:
166             name: {{ include "common.fullname" . }}
167             items:
168             - key: logback.xml
169               path: logback.xml
170             - key: cadi.properties
171               path: cadi.properties
172             - key: optimizer.properties
173               path: optimizer.properties
174             - key: liquibase.properties
175               path: liquibase.properties
176         - name:  {{ include "common.fullname" . }}-logs
177           emptyDir: {}
178         - name: {{ include "common.fullname" . }}-certs
179           secret:
180             secretName: {{ include "common.release" . }}-{{ .Values.global.commonConfigPrefix }}-certs
181       imagePullSecrets:
182       - name: "{{ include "common.namespace" . }}-docker-registry-key"