diff --git a/stable/mysql/README.md b/stable/mysql/README.md index bc45f8d5c0..66e2c7f8f7 100644 --- a/stable/mysql/README.md +++ b/stable/mysql/README.md @@ -56,6 +56,8 @@ The following tables lists the configurable parameters of the MySQL chart and th | `persistence.size` | Size of persistent volume claim | 8Gi RW | | `persistence.storageClass` | Type of persistent volume claim | nil (uses alpha storage class annotation) | | `persistence.accessMode` | ReadWriteOnce or ReadOnly | ReadWriteOnce | +| `persistence.existingClaim`| Name of existing persistent volume | `nil` +| `persistence.subPath` | Subdirectory of the volume to mount | `nil` | `resources` | CPU/Memory resource requests/limits | Memory: `256Mi`, CPU: `100m` | Some of the parameters above map to the env variables defined in the [MySQL DockerHub image](https://hub.docker.com/_/mysql/). diff --git a/stable/mysql/templates/deployment.yaml b/stable/mysql/templates/deployment.yaml index dfd0ee34a8..4ab8c7d631 100644 --- a/stable/mysql/templates/deployment.yaml +++ b/stable/mysql/templates/deployment.yaml @@ -21,6 +21,9 @@ spec: "volumeMounts": [ { "name": "data", + {{- if .Values.persistence.subPath }} + "subPath": "{{ .Values.persistence.subPath }}", + {{- end }} "mountPath": "/var/lib/mysql" } ], @@ -86,11 +89,14 @@ spec: volumeMounts: - name: data mountPath: /var/lib/mysql + {{- if .Values.persistence.subPath }} + subPath: {{ .Values.persistence.subPath }} + {{- end }} volumes: - name: data {{- if .Values.persistence.enabled }} persistentVolumeClaim: - claimName: {{ template "fullname" . }} + claimName: {{ .Values.persistence.existingClaim | default (include "fullname" .) }} {{- else }} emptyDir: {} {{- end -}} diff --git a/stable/mysql/templates/pvc.yaml b/stable/mysql/templates/pvc.yaml index 6a21fe551b..0136362a7c 100644 --- a/stable/mysql/templates/pvc.yaml +++ b/stable/mysql/templates/pvc.yaml @@ -1,4 +1,4 @@ -{{- if .Values.persistence.enabled }} +{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }} kind: PersistentVolumeClaim apiVersion: v1 metadata: