blob: 601057ff6f15f2ce2659ef02ee8105b019525f1b [file] [log] [blame]
vaibhavjayasea9aee02018-08-31 06:22:26 +00001# Copyright © 2018 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
vitalied1e5876c2018-03-29 10:24:27 -050015apiVersion: apps/v1beta1
16kind: StatefulSet
17metadata:
18 name: {{ include "common.fullname" . }}
19 namespace: {{ include "common.namespace" . }}
20 labels:
21 app: {{ include "common.fullname" . }}
22 chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
23 release: "{{ .Release.Name }}"
24 heritage: "{{ .Release.Service }}"
25spec:
pramod47b1b822018-08-28 15:41:45 +000026 serviceName: {{ .Values.service.name }}
vitalied1e5876c2018-03-29 10:24:27 -050027 replicas: {{ .Values.replicaCount }}
28 template:
29 metadata:
30 labels:
31 app: {{ include "common.fullname" . }}
sushil masal08ef7092019-02-21 16:21:51 +053032 chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
33 release: "{{ .Release.Name }}"
34 heritage: "{{ .Release.Service }}"
vitalied1e5876c2018-03-29 10:24:27 -050035 annotations:
36 pod.alpha.kubernetes.io/initialized: "true"
37 spec:
38 {{- if .Values.nodeSelector }}
39 nodeSelector:
40{{ toYaml .Values.nodeSelector | indent 8 }}
41 {{- end }}
42 volumes:
43 {{- if .Values.externalConfig }}
44 - name: config
45 configMap:
Jerry Floodf406ab82018-10-23 07:10:48 -040046 name: {{ include "common.fullname" . }}-external-config
vitalied1e5876c2018-03-29 10:24:27 -050047 {{- end}}
48 - name: localtime
49 hostPath:
50 path: /etc/localtime
51 imagePullSecrets:
52 - name: {{ include "common.namespace" . }}-docker-registry-key
53 containers:
pramod47b1b822018-08-28 15:41:45 +000054 - name: {{ include "common.name" . }}
BorislavGdf11cd52018-05-06 12:55:20 +000055 image: "{{ include "common.repository" . }}/{{ .Values.image }}"
vitalied1e5876c2018-03-29 10:24:27 -050056 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy | quote}}
57 env:
58 - name: POD_NAMESPACE
59 valueFrom:
60 fieldRef:
61 apiVersion: v1
62 fieldPath: metadata.namespace
63 - name: MYSQL_USER
64 value: {{ default "" .Values.config.userName | quote }}
65 - name: MYSQL_PASSWORD
66 valueFrom:
67 secretKeyRef:
68 name: {{ template "common.fullname" . }}
69 key: user-password
70 - name: MYSQL_DATABASE
71 value: {{ default "" .Values.config.mysqlDatabase | quote }}
72 - name: MYSQL_ROOT_PASSWORD
73 valueFrom:
74 secretKeyRef:
75 name: {{ template "common.fullname" . }}
76 key: db-root-password
77 ports:
78 - containerPort: {{ .Values.service.internalPort }}
Mike Elliott4c88b2d2018-09-13 09:32:08 -040079 name: {{ .Values.service.portName }}
vitalied1e5876c2018-03-29 10:24:27 -050080 - containerPort: {{ .Values.service.sstPort }}
Mike Elliott4c88b2d2018-09-13 09:32:08 -040081 name: {{ .Values.service.sstPortName }}
vitalied1e5876c2018-03-29 10:24:27 -050082 - containerPort: {{ .Values.service.replicationPort }}
83 name: {{ .Values.service.replicationName }}
84 - containerPort: {{ .Values.service.istPort }}
Mike Elliott4c88b2d2018-09-13 09:32:08 -040085 name: {{ .Values.service.istPortName }}
vitalied1e5876c2018-03-29 10:24:27 -050086 readinessProbe:
87 exec:
88 command:
89 - /usr/share/container-scripts/mysql/readiness-probe.sh
90 initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
91 periodSeconds: {{ .Values.readiness.periodSeconds }}
92 {{- if eq .Values.liveness.enabled true }}
93 livenessProbe:
94 exec:
95 command: ["mysqladmin", "ping"]
96 initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
97 periodSeconds: {{ .Values.liveness.periodSeconds }}
98 timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
99 {{- end }}
100 resources:
Mandeep Khinda5e3f36a2018-09-24 15:25:42 +0000101{{ include "common.resources" . | indent 12 }}
vitalied1e5876c2018-03-29 10:24:27 -0500102 volumeMounts:
103 {{- if .Values.externalConfig }}
104 - mountPath: /etc/config
105 name: config
106 {{- end}}
107 - mountPath: /etc/localtime
108 name: localtime
109 readOnly: true
110{{- if .Values.persistence.enabled }}
111 - mountPath: /var/lib/mysql
112 name: {{ include "common.fullname" . }}-data
vitalied1e5876c2018-03-29 10:24:27 -0500113 initContainers:
114 - name: mariadb-galera-prepare
BorislavGdf11cd52018-05-06 12:55:20 +0000115 image: "{{ include "common.repository" . }}/{{ .Values.imageInit }}"
vitalied1e5876c2018-03-29 10:24:27 -0500116 command: ["sh", "-c", "chown -R 27:27 /var/lib/mysql"]
117 volumeMounts:
118 - name: {{ include "common.fullname" . }}-data
119 mountPath: /var/lib/mysql
120 volumeClaimTemplates:
121 - metadata:
122 name: {{ include "common.fullname" . }}-data
pramod47b1b822018-08-28 15:41:45 +0000123 labels:
124 name: {{ include "common.fullname" . }}
sushil masal08ef7092019-02-21 16:21:51 +0530125 chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
126 release: "{{ .Release.Name }}"
127 heritage: "{{ .Release.Service }}"
vitalied1e5876c2018-03-29 10:24:27 -0500128 spec:
129 accessModes:
130 - {{ .Values.persistence.accessMode | quote }}
pramod47b1b822018-08-28 15:41:45 +0000131 storageClassName: {{ include "common.fullname" . }}-data
vitalied1e5876c2018-03-29 10:24:27 -0500132 resources:
133 requests:
134 storage: {{ .Values.persistence.size | quote }}
Alexis de Talhouët634b4552018-10-28 21:56:33 -0400135 selector:
136 matchLabels:
137 name: {{ include "common.fullname" . }}
BorislavGdf11cd52018-05-06 12:55:20 +0000138{{- end }}