updating helm/docker files and database config files
[it/otf.git] / otf-helm / otf / charts / databases / mysqldb / templates / deployment.yaml
1 apiVersion: apps/v1
2 kind: Deployment
3 metadata:
4   name: {{ template "mysql.fullname" . }}
5   namespace: {{ .Release.Namespace }}
6   labels:
7     app: {{ template "mysql.fullname" . }}
8     chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
9     release: "{{ .Release.Name }}"
10     heritage: "{{ .Release.Service }}"
11 {{- with .Values.deploymentAnnotations }}
12   annotations:
13 {{ toYaml . | indent 4 }}
14 {{- end }}
15
16 spec:
17   strategy:
18 {{ toYaml .Values.strategy | indent 4 }}
19   selector:
20     matchLabels:
21       app: {{ template "mysql.fullname" . }}
22       release: {{ .Release.Name }}
23   template:
24     metadata:
25       labels:
26         app: {{ template "mysql.fullname" . }}
27         release: {{ .Release.Name }}
28 {{- with .Values.podLabels }}
29 {{ toYaml . | indent 8 }}
30 {{- end }}
31 {{- with .Values.podAnnotations }}
32       annotations:
33 {{ toYaml . | indent 8 }}
34 {{- end }}
35     spec:
36       {{- if .Values.schedulerName }}
37       schedulerName: "{{ .Values.schedulerName }}"
38       {{- end }}
39       {{- if .Values.imagePullSecrets }}
40       imagePullSecrets:
41 {{ toYaml .Values.imagePullSecrets | indent 8 }}
42       {{- end }}
43       {{- if .Values.priorityClassName }}
44       priorityClassName: "{{ .Values.priorityClassName }}"
45       {{- end }}
46       {{- if .Values.securityContext.enabled }}
47       securityContext:
48         fsGroup: {{ .Values.securityContext.fsGroup }}
49         runAsUser: {{ .Values.securityContext.runAsUser }}
50       {{- end }}
51       serviceAccountName: {{ template "mysql.serviceAccountName" . }}
52       initContainers:
53       - name: "remove-lost-found"
54         image: "{{ .Values.busybox.image}}:{{ .Values.busybox.tag }}"
55         imagePullPolicy: {{ .Values.imagePullPolicy | quote }}
56         resources:
57 {{ toYaml .Values.initContainer.resources | indent 10 }}
58         command:  ["rm", "-fr", "/var/lib/mysql/lost+found"]
59         volumeMounts:
60         - name: data
61           mountPath: /var/lib/mysql
62           {{- if .Values.persistence.subPath }}
63           subPath: {{ .Values.persistence.subPath }}
64           {{- end }}
65       {{- if .Values.extraInitContainers }}
66 {{ tpl .Values.extraInitContainers . | indent 6 }}
67       {{- end }}
68       {{- if .Values.nodeSelector }}
69       nodeSelector:
70 {{ toYaml .Values.nodeSelector | indent 8 }}
71       {{- end }}
72       {{- if .Values.affinity }}
73       affinity:
74 {{ toYaml .Values.affinity | indent 8 }}
75       {{- end }}
76       {{- if .Values.tolerations }}
77       tolerations:
78 {{ toYaml .Values.tolerations | indent 8 }}
79       {{- end }}
80       containers:
81       - name: {{ template "mysql.fullname" . }}
82         image: "{{ .Values.image }}:{{ .Values.imageTag }}"
83         imagePullPolicy: {{ .Values.imagePullPolicy | quote }}
84
85         {{- with .Values.args }}
86         args:
87         {{- range . }}
88           - {{ . | quote }}
89         {{- end }}
90         {{- end }}
91         resources:
92 {{ toYaml .Values.resources | indent 10 }}
93         env:
94         {{- if .Values.mysqlAllowEmptyPassword }}
95         - name: MYSQL_ALLOW_EMPTY_PASSWORD
96           value: "true"
97         {{- end }}
98         {{- if not (and .Values.allowEmptyRootPassword (not .Values.mysqlRootPassword)) }}
99         - name: MYSQL_ROOT_PASSWORD
100           valueFrom:
101             secretKeyRef:
102               # name: {{ template "mysql.secretName" . }}
103               name: mysql
104               key: mysql-root-password
105               {{- if .Values.mysqlAllowEmptyPassword }}
106               optional: true
107               {{- end }}
108         {{- end }}
109         {{- if not (and .Values.allowEmptyRootPassword (not .Values.mysqlPassword)) }}
110         - name: MYSQL_PASSWORD
111           valueFrom:
112             secretKeyRef:
113               # name: {{ template "mysql.secretName" . }}
114               name: mysql
115               key: mysql-password
116               {{- if or .Values.mysqlAllowEmptyPassword (empty .Values.mysqlUser) }}
117               optional: true
118               {{- end }}
119         {{- end }}
120         - name: MYSQL_USER
121           value: {{ default "" .Values.mysqlUser | quote }}
122         - name: MYSQL_DATABASE
123           value: {{ default "" .Values.mysqlDatabase | quote }}
124         {{- if .Values.timezone }}
125         - name: TZ
126           value: {{ .Values.timezone }}
127         {{- end }}
128         {{- if .Values.extraEnvVars }}
129 {{ tpl .Values.extraEnvVars . | indent 8 }}
130         {{- end }}
131         ports:
132         - name: mysql
133           containerPort: 3306
134         livenessProbe:
135           exec:
136             command:
137             {{- if .Values.mysqlAllowEmptyPassword }}
138             - mysqladmin
139             - ping
140             {{- else }}
141             - sh
142             - -c
143             - "mysqladmin ping -u root -p${MYSQL_ROOT_PASSWORD}"
144             {{- end }}
145           initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
146           periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
147           timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
148           successThreshold: {{ .Values.livenessProbe.successThreshold }}
149           failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
150         readinessProbe:
151           exec:
152             command:
153             {{- if .Values.mysqlAllowEmptyPassword }}
154             - mysqladmin
155             - ping
156             {{- else }}
157             - sh
158             - -c
159             - "mysqladmin ping -u root -p${MYSQL_ROOT_PASSWORD}"
160             {{- end }}
161           initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
162           periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
163           timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
164           successThreshold: {{ .Values.readinessProbe.successThreshold }}
165           failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
166         volumeMounts:
167         - name: data
168           mountPath: /var/lib/mysql
169           {{- if .Values.persistence.subPath }}
170           subPath: {{ .Values.persistence.subPath }}
171           {{- end }}
172         {{- if .Values.configurationFiles }}
173         {{- range $key, $val := .Values.configurationFiles }}
174         - name: configurations
175           mountPath: {{ $.Values.configurationFilesPath }}{{ $key }}
176           subPath: {{ $key }}
177         {{- end -}}
178         {{- end }}
179         {{- if .Values.initializationFiles }}
180         - name: migrations
181           mountPath: /docker-entrypoint-initdb.d
182         {{- end }}
183         {{- if .Values.ssl.enabled }}
184         - name: certificates
185           mountPath: /ssl
186         {{- end }}
187         {{- if .Values.extraVolumeMounts }}
188 {{ tpl .Values.extraVolumeMounts . | indent 8 }}
189         {{- end }}
190       {{- if .Values.metrics.enabled }}
191       - name: metrics
192         image: "{{ .Values.metrics.image }}:{{ .Values.metrics.imageTag }}"
193         imagePullPolicy: {{ .Values.metrics.imagePullPolicy | quote }}
194         {{- if .Values.mysqlAllowEmptyPassword }}
195         command:
196         - 'sh'
197         - '-c'
198         - 'DATA_SOURCE_NAME="root@(localhost:3306)/" /bin/mysqld_exporter'
199         {{- else }}
200         env:
201         - name: MYSQL_ROOT_PASSWORD
202           valueFrom:
203             secretKeyRef:
204               # name: {{ template "mysql.secretName" . }}
205               name: mysql
206               key: mysql-root-password
207         command:
208         - 'sh'
209         - '-c'
210         - 'DATA_SOURCE_NAME="root:$MYSQL_ROOT_PASSWORD@(localhost:3306)/" /bin/mysqld_exporter'
211         {{- end }}
212         {{- range $f := .Values.metrics.flags }}
213         - {{ $f | quote }}
214         {{- end }}
215         ports:
216         - name: metrics
217           containerPort: 9104
218         livenessProbe:
219           httpGet:
220             path: /
221             port: metrics
222           initialDelaySeconds: {{ .Values.metrics.livenessProbe.initialDelaySeconds }}
223           timeoutSeconds: {{ .Values.metrics.livenessProbe.timeoutSeconds }}
224         readinessProbe:
225           httpGet:
226             path: /
227             port: metrics
228           initialDelaySeconds: {{ .Values.metrics.readinessProbe.initialDelaySeconds }}
229           timeoutSeconds: {{ .Values.metrics.readinessProbe.timeoutSeconds }}
230         resources:
231 {{ toYaml .Values.metrics.resources | indent 10 }}
232       {{- end }}
233       volumes:
234       {{- if .Values.configurationFiles }}
235       - name: configurations
236         configMap:
237           name: {{ template "mysql.fullname" . }}-configuration
238       {{- end }}
239       {{- if .Values.initializationFiles }}
240       - name: migrations
241         configMap:
242           name: {{ template "mysql.fullname" . }}-initialization
243       {{- end }}
244       {{- if .Values.ssl.enabled }}
245       - name: certificates
246         secret:
247           secretName: {{ .Values.ssl.secret }}
248       {{- end }}
249       - name: data
250       {{- if .Values.persistence.enabled }}
251         persistentVolumeClaim:
252           claimName: {{ .Values.persistence.existingClaim | default (include "mysql.fullname" .) }}
253       {{- else }}
254         emptyDir: {}
255       {{- end -}}
256       {{- if .Values.extraVolumes }}
257 {{ tpl .Values.extraVolumes . | indent 6 }}
258       {{- end }}