Merge "clamphealth check"
[oom.git] / kubernetes / common / mysql / templates / statefulset.yaml
index 0304639..0f340f0 100644 (file)
@@ -1,4 +1,5 @@
-# Copyright © 2017-2018 Amdocs, Bell Canada
+{{/*
+# Copyright © 2017 Amdocs, Bell Canada
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -11,6 +12,7 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
+*/}}
 
 apiVersion: apps/v1beta1
 kind: StatefulSet
@@ -49,7 +51,7 @@ spec:
         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
 #{{ end }}
       - name: init-mysql
-        image: "{{ .Values.repository | default .Values.repository }}/{{ .Values.image }}"
+        image: "{{ .Values.dockerHubRepository }}/{{ .Values.image }}"
         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
         command:
         - bash
@@ -98,21 +100,19 @@ spec:
           echo ${BASH_REMATCH}
           [[ $ordinal -eq 0 ]] && exit 0
           # Clone data from previous peer.
-          ncat --recv-only {{ include "common.fullname" . }}-$(($ordinal-1)).{{ .Values.service.name }}.{{ include "common.namespace" . }} 3307 | xbstream -x -C /var/lib/mysql
+          ncat --recv-only {{ include "common.fullname" . }}-$(($ordinal-1)).{{ .Values.service.name }}.{{ include "common.namespace" . }} 3307 | xbstream -x -C {{ .Values.persistence.mysqlPath }}
           # Prepare the backup.
           xtrabackup --user=root --password=$MYSQL_ROOT_PASSWORD --prepare --target-dir=/var/lib/mysql
-          ls -l /var/lib/mysql
+          ls -l {{ .Values.persistence.mysqlPath }}
         volumeMounts:
-        - name: {{ include "common.fullname" . }}-data
-          mountPath: /var/lib/mysql
-          subPath: mysql
+        - name: {{ include "common.fullname" . }}-mysql
+          mountPath: {{ .Values.persistence.mysqlPath }}
         - name: conf
           mountPath: /etc/mysql/conf.d
 
       containers:
-        #sdnc-db-container
         - name: {{ include "common.name" . }}
-          image: "{{ .Values.repository | default .Values.repository }}/{{ .Values.image }}"
+          image: "{{ .Values.dockerHubRepository }}/{{ .Values.image }}"
           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
           ports:
           - containerPort: {{ .Values.service.internalPort }}
@@ -142,9 +142,8 @@ spec:
             - name: MYSQL_ALLOW_EMPTY_PASSWORD
               value: {{ .Values.config.dbAllowEmptyPassword | default "0" | quote }}
           volumeMounts:
-          - mountPath: /var/lib/mysql
-            name: {{ include "common.fullname" . }}-data
-            subPath: mysql
+          - mountPath: {{ .Values.persistence.mysqlPath }}
+            name: {{ include "common.fullname" . }}-mysql
           - mountPath: /etc/mysql/conf.d
             name: conf
           resources:
@@ -175,7 +174,7 @@ spec:
           - "-c"
           - |
             set -ex
-            cd /var/lib/mysql
+            cd {{ .Values.persistence.mysqlPath }}
             ls -l
             # Determine binlog position of cloned data, if any.
             if [[ -f xtrabackup_slave_info ]]; then
@@ -223,9 +222,8 @@ spec:
             exec ncat --listen --keep-open --send-only --max-conns=1 3307 -c \
               "xtrabackup --user=root --password=$MYSQL_ROOT_PASSWORD --backup --slave-info --stream=xbstream --host=$mysqlhost"
           volumeMounts:
-          - name: {{ include "common.fullname" . }}-data
-            mountPath: /var/lib/mysql
-            subPath: mysql
+          - name: {{ include "common.fullname" . }}-mysql
+            mountPath: {{ .Values.persistence.mysqlPath }}
           - name: conf
             mountPath: /etc/mysql/conf.d
       volumes:
@@ -237,22 +235,20 @@ spec:
       - name: localtime
         hostPath:
           path: /etc/localtime
-      - name: {{ include "common.fullname" . }}-data
-#{{ if not .Values.disableNfsProvisioner }}
+      - name: {{ include "common.fullname" . }}-mysql
+  {{ if not .Values.persistence.enabled }}
+      - name: {{ include "common.fullname" . }}-mysql
+        emptyDir: {}
+  {{ else }}
   volumeClaimTemplates:
   - metadata:
-      name: {{ include "common.fullname" . }}-data
-      annotations:
-        volume.beta.kubernetes.io/storage-class: "{{ include "common.fullname" . }}-data"
+      name: {{ include "common.fullname" . }}-mysql
+      labels:
+        name: {{ include "common.fullname" . }}
     spec:
-      accessModes: ["ReadWriteMany"]
+      accessModes: [ {{ .Values.persistence.accessMode }} ]
+      storageClassName: {{ include "common.fullname" . }}-mysql
       resources:
         requests:
-          storage: 1Gi
-#{{ else if .Values.persistence.enabled }}
-        persistentVolumeClaim:
-          claimName: {{ include "common.fullname" . }}-data
-#{{ else }}
-        emptyDir: {}
-#{{ end }}
-
+          storage: {{ .Values.persistence.size }}
+  {{ end }}