diff options
Diffstat (limited to 'kubernetes/common/mysql')
-rw-r--r-- | kubernetes/common/mysql/templates/pv.yaml | 30 | ||||
-rw-r--r-- | kubernetes/common/mysql/templates/pvc.yaml | 39 | ||||
-rw-r--r-- | kubernetes/common/mysql/templates/service.yaml | 10 | ||||
-rw-r--r-- | kubernetes/common/mysql/templates/statefulset.yaml | 41 | ||||
-rw-r--r-- | kubernetes/common/mysql/templates/storageclass.yaml | 2 | ||||
-rw-r--r-- | kubernetes/common/mysql/values.yaml | 9 |
6 files changed, 64 insertions, 67 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/service.yaml b/kubernetes/common/mysql/templates/service.yaml index ed4f72adc5..dc63e31029 100644 --- a/kubernetes/common/mysql/templates/service.yaml +++ b/kubernetes/common/mysql/templates/service.yaml @@ -115,15 +115,15 @@ metadata: statefulset.kubernetes.io/pod-name: {{ include "common.fullname" . }}-0 spec: ports: - - name: {{ .Values.service.internalPort }} + - name: {{ .Values.service.portName | default .Values.service.name }}-1 port: {{ .Values.service.internalPort }} targetPort: {{ .Values.service.internalPort }} - nodePort: {{ .Values.global.nodePortPrefix | default .Values.nodePortPrefix }}{{ .Values.service.externalPort1 }} - - name: {{ .Values.xtrabackup.internalPort }} + nodePort: {{ .Values.global.nodePortPrefix | default .Values.nodePortPrefix }}{{ .Values.service.nodeport1 }} + - name: {{ .Values.service.portName | default .Values.service.name }}-2 port: {{ .Values.xtrabackup.internalPort }} targetPort: {{ .Values.xtrabackup.internalPort }} - nodePort: {{ .Values.global.nodePortPrefix | default .Values.nodePortPrefix }}{{ .Values.service.externalPort2 }} - type: NodePort + nodePort: {{ .Values.global.nodePortPrefix | default .Values.nodePortPrefix }}{{ .Values.service.nodeport2 }} + type: {{ .Values.service.type }} selector: statefulset.kubernetes.io/pod-name: {{ include "common.fullname" . }}-0 release: {{ .Release.Name }} 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 028a440c01..6805aa5e6c 100644 --- a/kubernetes/common/mysql/values.yaml +++ b/kubernetes/common/mysql/values.yaml @@ -17,7 +17,6 @@ ################################################################# global: nodePortPrefix: 302 - repositorySecret: eyJuZXh1czMub25hcC5vcmc6MTAwMDEiOnsidXNlcm5hbWUiOiJkb2NrZXIiLCJwYXNzd29yZCI6ImRvY2tlciIsImVtYWlsIjoiQCIsImF1dGgiOiJaRzlqYTJWeU9tUnZZMnRsY2c9PSJ9fQ== persistence: {} readinessRepository: oomk8s readinessImage: readiness-check:2.0.0 @@ -59,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 @@ -73,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 @@ -87,6 +87,9 @@ service: mountdPort: 20048 rpcbindPort: 111 rpcbindUdpPort: 111 + type: NodePort + nodeport1: 72 + nodeport2: 73 ingress: enabled: false |