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