From fb13fa3d9d5093758eee7abe6405718982ccf895 Mon Sep 17 00:00:00 2001 From: Philip Champon Date: Wed, 5 Apr 2017 13:55:50 -0400 Subject: [PATCH] [stable/mariadb] add existing persistent volume claim (#715) * add existing persistent volume claim, for mariadb * cleanup templating * fix indentation in values.yaml --- stable/mariadb/Chart.yaml | 2 +- stable/mariadb/README.md | 41 +++++++++++++++--------- stable/mariadb/templates/deployment.yaml | 2 +- stable/mariadb/templates/pvc.yaml | 2 +- stable/mariadb/values.yaml | 6 ++++ 5 files changed, 34 insertions(+), 19 deletions(-) diff --git a/stable/mariadb/Chart.yaml b/stable/mariadb/Chart.yaml index d0badb8276..32608ace94 100644 --- a/stable/mariadb/Chart.yaml +++ b/stable/mariadb/Chart.yaml @@ -1,5 +1,5 @@ name: mariadb -version: 0.5.14 +version: 0.6.0 description: Fast, reliable, scalable, and easy to use open-source relational database system. MariaDB Server is intended for mission-critical, heavy-load production systems as well as for embedding into mass-deployed software. keywords: - mariadb diff --git a/stable/mariadb/README.md b/stable/mariadb/README.md index a4e74852aa..50b8bafe63 100644 --- a/stable/mariadb/README.md +++ b/stable/mariadb/README.md @@ -45,21 +45,21 @@ The command removes all the Kubernetes components associated with the chart and The following tables lists the configurable parameters of the MariaDB chart and their default values. -| Parameter | Description | Default | -| ----------------------- | ---------------------------------- | ---------------------------------------------------------- | -| `image` | MariaDB image | `bitnami/mariadb:{VERSION}` | -| `imagePullPolicy` | Image pull policy. | `IfNotPresent` | -| `mariadbRootPassword` | Password for the `root` user. | `nil` | -| `mariadbUser` | Username of new user to create. | `nil` | -| `mariadbPassword` | Password for the new user. | `nil` | -| `mariadbDatabase` | Name for new database to create. | `nil` | -| `persistence.enabled` | Use a PVC to persist data | `true` | -| `persistence.storageClass` | Storage class of backing PVC | `nil` (uses alpha storage class annotation) | -| `persistence.accessMode` | Use volume as ReadOnly or ReadWrite | `ReadWriteOnce` | -| `persistence.size` | Size of data volume | `8Gi` | -| `resources` | CPU/Memory resource requests/limits | Memory: `256Mi`, CPU: `250m` | -| `serviceType` | Kubernetes service type | `ClusterIP` | -| `config` | Multi-line string for my.cnf configuration | `nil` | +| Parameter | Description | Default | +| ----------------------- | ---------------------------------- | ---------------------------------------------------------- | +| `image` | MariaDB image | `bitnami/mariadb:{VERSION}` | +| `imagePullPolicy` | Image pull policy. | `IfNotPresent` | +| `mariadbRootPassword` | Password for the `root` user. | `nil` | +| `mariadbUser` | Username of new user to create. | `nil` | +| `mariadbPassword` | Password for the new user. | `nil` | +| `mariadbDatabase` | Name for new database to create. | `nil` | +| `persistence.enabled` | Use a PVC to persist data | `true` | +| `persistence.existingClaim` | Use an existing PVC | `nil` | +| `persistence.storageClass` | Storage class of backing PVC | `nil` (uses alpha storage class annotation) | +| `persistence.accessMode` | Use volume as ReadOnly or ReadWrite | `ReadWriteOnce` | +| `persistence.size` | Size of data volume | `8Gi` | +| `resources` | CPU/Memory resource requests/limits | Memory: `256Mi`, CPU: `250m` | +| `config` | Multi-line string for my.cnf configuration | `nil` | The above parameters map to the env variables defined in [bitnami/mariadb](http://github.com/bitnami/bitnami-docker-mariadb). For more information please refer to the [bitnami/mariadb](http://github.com/bitnami/bitnami-docker-mariadb) image documentation. @@ -107,4 +107,13 @@ helm install --name my-release -f mariadb-values.yaml stable/mariadb The [Bitnami MariaDB](https://github.com/bitnami/bitnami-docker-mariadb) image stores the MariaDB data and configurations at the `/bitnami/mariadb` path of the container. -The chart mounts a [Persistent Volume](kubernetes.io/docs/user-guide/persistent-volumes/) volume at this location. The volume is created using dynamic volume provisioning. +The chart mounts a [Persistent Volume](kubernetes.io/docs/user-guide/persistent-volumes/) volume at this location. The volume is created using dynamic volume provisioning, by default. An existing PersistentVolumeClaim can be defined. + +### Existing PersistentVolumeClaims + +1. Create the PersistentVolume +1. Create the PersistentVolumeClaim +1. Install the chart +```bash +$ helm install --set persistence.existingClaim=PVC_NAME postgresql +``` diff --git a/stable/mariadb/templates/deployment.yaml b/stable/mariadb/templates/deployment.yaml index 3903e1ddde..ac3f7a18f3 100644 --- a/stable/mariadb/templates/deployment.yaml +++ b/stable/mariadb/templates/deployment.yaml @@ -83,7 +83,7 @@ spec: - name: data {{- if .Values.persistence.enabled }} persistentVolumeClaim: - claimName: {{ template "fullname" . }} + claimName: {{ .Values.persistence.existingClaim | default (include "fullname" .) }} {{- else }} emptyDir: {} {{- end -}} diff --git a/stable/mariadb/templates/pvc.yaml b/stable/mariadb/templates/pvc.yaml index 6a21fe551b..0136362a7c 100644 --- a/stable/mariadb/templates/pvc.yaml +++ b/stable/mariadb/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: diff --git a/stable/mariadb/values.yaml b/stable/mariadb/values.yaml index d1e968e4aa..fe97fe1470 100644 --- a/stable/mariadb/values.yaml +++ b/stable/mariadb/values.yaml @@ -34,6 +34,12 @@ serviceType: ClusterIP ## persistence: enabled: true + + ## A manually managed Persistent Volume and Claim + ## Requires persistence.enabled: true + ## If defined, PVC must be created manually before volume will be bound + # existingClaim: + ## If defined, volume.beta.kubernetes.io/storage-class: ## Default: volume.alpha.kubernetes.io/storage-class: default ##