Merge "Add Common Helm Chart "mariadb-galera""
[oom.git] / kubernetes / policy / charts / mariadb / templates / deployment.yaml
1 # Copyright © 2017 Amdocs, Bell Canada
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: {{ .Release.Name }}
24     heritage: {{ .Release.Service }}
25 spec:
26   replicas: {{ .Values.replicaCount }}
27   template:
28     metadata:
29       labels:
30         app: {{ include "common.name" . }}
31         release: {{ .Release.Name }}
32     spec:
33       containers:
34         - name: {{ include "common.name" . }}
35           image: "{{ .Values.global.repository | default .Values.repository }}/{{ .Values.image }}"
36           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
37           ports:
38           - containerPort: {{ .Values.service.internalPort }}
39           # disable liveness probe when breakpoints set in debugger
40           # so K8s doesn't restart unresponsive container 
41           {{- if eq .Values.liveness.enabled true }}
42           args:
43           - --lower-case-table-names=1
44           livenessProbe:
45             tcpSocket:
46               port: {{ .Values.service.internalPort }}
47             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
48             periodSeconds: {{ .Values.liveness.periodSeconds }}
49           {{ end -}}
50           readinessProbe:
51             tcpSocket:
52               port: {{ .Values.service.internalPort }}
53             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
54             periodSeconds: {{ .Values.readiness.periodSeconds }}
55           env:
56           - name: MYSQL_ROOT_PASSWORD
57             valueFrom:
58               secretKeyRef:
59                 name: {{ template "common.fullname" . }}-secret
60                 key: db-root-password
61           - name: MYSQL_USER
62             value: policy_user
63           - name: MYSQL_PASSWORD
64             valueFrom:
65               secretKeyRef:
66                 name: {{ template "common.fullname" . }}-secret
67                 key: db-user-password
68           volumeMounts:
69           - mountPath: /etc/localtime
70             name: localtime
71             readOnly: true
72           - mountPath: /docker-entrypoint-initdb.d
73             name: mariadb-conf
74           - mountPath: /var/lib/mysql
75             name: mariadb-data
76           resources:
77 {{ toYaml .Values.resources | indent 12 }}
78         {{- if .Values.nodeSelector }}
79         nodeSelector:
80 {{ toYaml .Values.nodeSelector | indent 10 }}
81         {{- end -}}
82         {{- if .Values.affinity }}
83         affinity:
84 {{ toYaml .Values.affinity | indent 10 }}
85         {{- end }}
86       volumes:
87         - name: localtime
88           hostPath:
89             path: /etc/localtime
90         - name: mariadb-conf
91           configMap:
92             name: {{ include "common.fullname" . }}-configmap
93             defaultMode: 0755
94         - name: mariadb-data
95         {{- if .Values.persistence.enabled }}
96           persistentVolumeClaim:
97             claimName: {{ include "common.fullname" . }}
98         {{- else }}
99           emptyDir: {}
100         {{- end }}
101       imagePullSecrets:
102       - name: "{{ include "common.namespace" . }}-docker-registry-key"