summaryrefslogtreecommitdiffstats
path: root/kubernetes/common/mysql
diff options
context:
space:
mode:
authorMandeep Khinda <Mandeep.Khinda@amdocs.com>2018-05-15 19:51:10 +0000
committerGerrit Code Review <gerrit@onap.org>2018-05-15 19:51:10 +0000
commit792b18625344b5ee726fa2b2137924dbd52fda22 (patch)
tree5ec9c561ef952de968d0921ed44f31fecee10fc8 /kubernetes/common/mysql
parent310f6aa9db9075c3999d6f421a9b0b94a918f93d (diff)
parentcffec6dd4954cff326791a7a8220ebbb26c9be04 (diff)
Merge "Add separate PV for each SDN-C MYSQL pod"
Diffstat (limited to 'kubernetes/common/mysql')
-rw-r--r--kubernetes/common/mysql/templates/pv.yaml30
-rw-r--r--kubernetes/common/mysql/templates/pvc.yaml39
-rw-r--r--kubernetes/common/mysql/templates/statefulset.yaml41
-rw-r--r--kubernetes/common/mysql/templates/storageclass.yaml2
-rw-r--r--kubernetes/common/mysql/values.yaml5
5 files changed, 56 insertions, 61 deletions
diff --git a/kubernetes/common/mysql/templates/pv.yaml b/kubernetes/common/mysql/templates/pv.yaml
index 824dcbb87b..3bef651916 100644
--- a/kubernetes/common/mysql/templates/pv.yaml
+++ b/kubernetes/common/mysql/templates/pv.yaml
@@ -15,10 +15,11 @@
*/}}
{{- if (and (and (.Values.persistence.enabled) (not .Values.persistence.existingClaim)) ( .Values.disableNfsProvisioner)) -}}
+{{ $pvNum := default 1 .Values.replicaCount | int }}
kind: PersistentVolume
apiVersion: v1
metadata:
- name: {{ include "common.fullname" . }}-data
+ name: {{ include "common.fullname" . }}-mysql0
namespace: {{ include "common.namespace" . }}
labels:
app: {{ include "common.name" . }}
@@ -31,8 +32,31 @@ spec:
storage: {{ .Values.persistence.size}}
accessModes:
- {{ .Values.persistence.accessMode }}
- storageClassName: "{{ include "common.fullname" . }}-data"
+ storageClassName: "{{ include "common.fullname" . }}-mysql"
persistentVolumeReclaimPolicy: {{ .Values.persistence.volumeReclaimPolicy }}
hostPath:
- path: {{ .Values.global.persistence.mountPath | default .Values.persistence.mountPath }}/{{ .Release.Name }}/{{ .Values.persistence.mountSubPath }}
+ path: {{ .Values.global.persistence.mountPath | default .Values.persistence.mountPath }}/{{ .Release.Name }}/{{ .Values.persistence.mountSubPath }}0
+{{ if gt $pvNum 1 }}
+---
+kind: PersistentVolume
+apiVersion: v1
+metadata:
+ name: {{ include "common.fullname" . }}-mysql1
+ namespace: {{ include "common.namespace" . }}
+ labels:
+ app: {{ include "common.fullname" . }}
+ chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
+ release: "{{ .Release.Name }}"
+ heritage: "{{ .Release.Service }}"
+ name: {{ include "common.fullname" . }}
+spec:
+ capacity:
+ storage: {{ .Values.persistence.size}}
+ accessModes:
+ - {{ .Values.persistence.accessMode }}
+ storageClassName: "{{ include "common.fullname" . }}-mysql"
+ persistentVolumeReclaimPolicy: {{ .Values.persistence.volumeReclaimPolicy }}
+ hostPath:
+ path: {{ .Values.global.persistence.mountPath | default .Values.persistence.mountPath }}/{{ .Release.Name }}/{{ .Values.persistence.mountSubPath }}1
+{{ end }}
{{- end -}}
diff --git a/kubernetes/common/mysql/templates/pvc.yaml b/kubernetes/common/mysql/templates/pvc.yaml
deleted file mode 100644
index d1558f131f..0000000000
--- a/kubernetes/common/mysql/templates/pvc.yaml
+++ /dev/null
@@ -1,39 +0,0 @@
-{{/*
-# 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.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# 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.
-*/}}
-
-{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) -}}
-kind: PersistentVolumeClaim
-apiVersion: v1
-metadata:
- name: {{ include "common.fullname" . }}-data
- namespace: {{ include "common.namespace" . }}
- labels:
- app: {{ include "common.fullname" . }}
- chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
- release: "{{ .Release.Name }}"
- heritage: "{{ .Release.Service }}"
-{{- if .Values.persistence.annotations }}
- annotations:
-{{ toYaml .Values.persistence.annotations | indent 4 }}
-{{- end }}
-spec:
- accessModes:
- - {{ .Values.persistence.accessMode }}
- resources:
- requests:
- storage: {{ .Values.persistence.size }}
- storageClassName: "{{ include "common.fullname" . }}-data"
-{{- end -}}
diff --git a/kubernetes/common/mysql/templates/statefulset.yaml b/kubernetes/common/mysql/templates/statefulset.yaml
index ff73b45620..0f340f00b5 100644
--- a/kubernetes/common/mysql/templates/statefulset.yaml
+++ b/kubernetes/common/mysql/templates/statefulset.yaml
@@ -100,13 +100,13 @@ 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
+ - name: {{ include "common.fullname" . }}-mysql
+ mountPath: {{ .Values.persistence.mysqlPath }}
- name: conf
mountPath: /etc/mysql/conf.d
@@ -142,8 +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
+ - mountPath: {{ .Values.persistence.mysqlPath }}
+ name: {{ include "common.fullname" . }}-mysql
- mountPath: /etc/mysql/conf.d
name: conf
resources:
@@ -174,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
@@ -222,8 +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
+ - name: {{ include "common.fullname" . }}-mysql
+ mountPath: {{ .Values.persistence.mysqlPath }}
- name: conf
mountPath: /etc/mysql/conf.d
volumes:
@@ -235,11 +235,20 @@ spec:
- name: localtime
hostPath:
path: /etc/localtime
- - name: {{ include "common.fullname" . }}-data
-#{{ if .Values.persistence.enabled }}
- persistentVolumeClaim:
- claimName: {{ include "common.fullname" . }}-data
-#{{ else }}
+ - name: {{ include "common.fullname" . }}-mysql
+ {{ if not .Values.persistence.enabled }}
+ - name: {{ include "common.fullname" . }}-mysql
emptyDir: {}
-#{{ end }}
-
+ {{ else }}
+ volumeClaimTemplates:
+ - metadata:
+ name: {{ include "common.fullname" . }}-mysql
+ labels:
+ name: {{ include "common.fullname" . }}
+ spec:
+ accessModes: [ {{ .Values.persistence.accessMode }} ]
+ storageClassName: {{ include "common.fullname" . }}-mysql
+ resources:
+ requests:
+ storage: {{ .Values.persistence.size }}
+ {{ end }}
diff --git a/kubernetes/common/mysql/templates/storageclass.yaml b/kubernetes/common/mysql/templates/storageclass.yaml
index 3cd502ea30..4edb477144 100644
--- a/kubernetes/common/mysql/templates/storageclass.yaml
+++ b/kubernetes/common/mysql/templates/storageclass.yaml
@@ -18,7 +18,7 @@
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
- name: "{{ include "common.fullname" . }}-data"
+ name: "{{ include "common.fullname" . }}-mysql"
namespace: {{ include "common.namespace" . }}
provisioner: {{ include "common.fullname" . }}/nfs
{{ end }}
diff --git a/kubernetes/common/mysql/values.yaml b/kubernetes/common/mysql/values.yaml
index 306c2d7fe0..b12e72d0a2 100644
--- a/kubernetes/common/mysql/values.yaml
+++ b/kubernetes/common/mysql/values.yaml
@@ -58,7 +58,7 @@ readiness:
## Persist data to a persitent volume
persistence:
- enabled: false
+ enabled: true
## A manually managed Persistent Volume and Claim
## Requires persistence.enabled: true
@@ -72,10 +72,11 @@ persistence:
## If undefined (the default) or set to null, no storageClassName spec is
## set, choosing the default provisioner. (gp2 on AWS, standard on
## GKE, AWS & OpenStack)
- accessMode: ReadWriteMany
+ accessMode: ReadWriteOnce
size: 1Gi
mountPath: /dockerdata-nfs
mountSubPath: "mysql/data"
+ mysqlPath: /var/lib/mysql
service:
name: mysql