blob: ed7e1fc578f132cd7f9094203fb1e6e0c6d79db0 [file] [log] [blame]
vitalied1e5876c2018-03-29 10:24:27 -05001apiVersion: apps/v1beta1
2kind: StatefulSet
3metadata:
4 name: {{ include "common.fullname" . }}
5 namespace: {{ include "common.namespace" . }}
6 labels:
7 app: {{ include "common.fullname" . }}
8 chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
9 release: "{{ .Release.Name }}"
10 heritage: "{{ .Release.Service }}"
11spec:
12 serviceName: {{ include "common.fullname" . }}
13 replicas: {{ .Values.replicaCount }}
14 template:
15 metadata:
16 labels:
17 app: {{ include "common.fullname" . }}
18 annotations:
19 pod.alpha.kubernetes.io/initialized: "true"
20 spec:
21 {{- if .Values.nodeSelector }}
22 nodeSelector:
23{{ toYaml .Values.nodeSelector | indent 8 }}
24 {{- end }}
25 volumes:
26 {{- if .Values.externalConfig }}
27 - name: config
28 configMap:
29 name: {{ include "common.fullname" . }}-externalConfig
30 {{- end}}
31 - name: localtime
32 hostPath:
33 path: /etc/localtime
34 imagePullSecrets:
35 - name: {{ include "common.namespace" . }}-docker-registry-key
36 containers:
37 - name: {{ include "common.fullname" . }}
BorislavGdf11cd52018-05-06 12:55:20 +000038 image: "{{ include "common.repository" . }}/{{ .Values.image }}"
vitalied1e5876c2018-03-29 10:24:27 -050039 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy | quote}}
40 env:
41 - name: POD_NAMESPACE
42 valueFrom:
43 fieldRef:
44 apiVersion: v1
45 fieldPath: metadata.namespace
46 - name: MYSQL_USER
47 value: {{ default "" .Values.config.userName | quote }}
48 - name: MYSQL_PASSWORD
49 valueFrom:
50 secretKeyRef:
51 name: {{ template "common.fullname" . }}
52 key: user-password
53 - name: MYSQL_DATABASE
54 value: {{ default "" .Values.config.mysqlDatabase | quote }}
55 - name: MYSQL_ROOT_PASSWORD
56 valueFrom:
57 secretKeyRef:
58 name: {{ template "common.fullname" . }}
59 key: db-root-password
60 ports:
61 - containerPort: {{ .Values.service.internalPort }}
62 name: {{ .Values.service.name }}
63 - containerPort: {{ .Values.service.sstPort }}
64 name: {{ .Values.service.sstName }}
65 - containerPort: {{ .Values.service.replicationPort }}
66 name: {{ .Values.service.replicationName }}
67 - containerPort: {{ .Values.service.istPort }}
68 name: {{ .Values.service.istName }}
69 readinessProbe:
70 exec:
71 command:
72 - /usr/share/container-scripts/mysql/readiness-probe.sh
73 initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
74 periodSeconds: {{ .Values.readiness.periodSeconds }}
75 {{- if eq .Values.liveness.enabled true }}
76 livenessProbe:
77 exec:
78 command: ["mysqladmin", "ping"]
79 initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
80 periodSeconds: {{ .Values.liveness.periodSeconds }}
81 timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
82 {{- end }}
83 resources:
84{{ toYaml .Values.resources | indent 12 }}
85 volumeMounts:
86 {{- if .Values.externalConfig }}
87 - mountPath: /etc/config
88 name: config
89 {{- end}}
90 - mountPath: /etc/localtime
91 name: localtime
92 readOnly: true
93{{- if .Values.persistence.enabled }}
94 - mountPath: /var/lib/mysql
95 name: {{ include "common.fullname" . }}-data
96 subPath: data
97 initContainers:
98 - name: mariadb-galera-prepare
BorislavGdf11cd52018-05-06 12:55:20 +000099 image: "{{ include "common.repository" . }}/{{ .Values.imageInit }}"
vitalied1e5876c2018-03-29 10:24:27 -0500100 command: ["sh", "-c", "chown -R 27:27 /var/lib/mysql"]
101 volumeMounts:
102 - name: {{ include "common.fullname" . }}-data
103 mountPath: /var/lib/mysql
104 volumeClaimTemplates:
105 - metadata:
106 name: {{ include "common.fullname" . }}-data
107 annotations:
108 {{- if .Values.persistence.storageClass }}
109 volume.beta.kubernetes.io/storage-class: {{ .Values.persistence.storageClass | quote }}
110 {{- else }}
111 volume.alpha.kubernetes.io/storage-class: default
112 {{- end }}
113 spec:
114 accessModes:
115 - {{ .Values.persistence.accessMode | quote }}
116 resources:
117 requests:
118 storage: {{ .Values.persistence.size | quote }}
BorislavGdf11cd52018-05-06 12:55:20 +0000119{{- end }}