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