diff --git a/stable/mariadb/Chart.yaml b/stable/mariadb/Chart.yaml index 16e08cd3ab..3d53e8fc4d 100644 --- a/stable/mariadb/Chart.yaml +++ b/stable/mariadb/Chart.yaml @@ -1,5 +1,5 @@ name: mariadb -version: 0.3.1 +version: 0.4.0 description: Chart for MariaDB keywords: - mariadb diff --git a/stable/mariadb/README.md b/stable/mariadb/README.md index 8948515966..09861ff884 100644 --- a/stable/mariadb/README.md +++ b/stable/mariadb/README.md @@ -60,6 +60,10 @@ The following tables lists the configurable parameters of the MariaDB chart and | `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 | `generic` | +| `persistence.accessMode` | Use volume as ReadOnly or ReadWrite | `ReadWriteOnce` | +| `persistence.size` | Size of data volume | `8Gi` | 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. @@ -85,38 +89,4 @@ $ helm install --name my-release -f values.yaml mariadb-x.x.x.tgz 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. -As a placeholder, the chart mounts an [emptyDir](http://kubernetes.io/docs/user-guide/volumes/#emptydir) volume at this location. - -> *"An emptyDir volume is first created when a Pod is assigned to a Node, and exists as long as that Pod is running on that node. When a Pod is removed from a node for any reason, the data in the emptyDir is deleted forever."* - -For persistence of the data you should replace the `emptyDir` volume with a persistent [storage volume](http://kubernetes.io/docs/user-guide/volumes/), else the data will be lost if the Pod is shutdown. - -### Step 1: Create a persistent disk - -You first need to create a persistent disk in the cloud platform your cluster is running. For example, on GCE you can use the `gcloud` tool to create a [gcePersistentDisk](http://kubernetes.io/docs/user-guide/volumes/#gcepersistentdisk): - -```bash -$ gcloud compute disks create --size=500GB --zone=us-central1-a mariadb-data-disk -``` - -### Step 2: Update `templates/deployment.yaml` - -Replace: - -```yaml - volumes: - - name: data - emptyDir: {} -``` - -with - -```yaml - volumes: - - name: data - gcePersistentDisk: - pdName: mariadb-data-disk - fsType: ext4 -``` - -[Install](#installing-the-chart) the chart after making these changes. +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. diff --git a/stable/mariadb/templates/deployment.yaml b/stable/mariadb/templates/deployment.yaml index 17833f1846..58153c2b8b 100644 --- a/stable/mariadb/templates/deployment.yaml +++ b/stable/mariadb/templates/deployment.yaml @@ -57,4 +57,9 @@ spec: mountPath: /bitnami/mariadb volumes: - name: data + {{- if .Values.persistence.enabled }} + persistentVolumeClaim: + claimName: {{ template "fullname" . }} + {{- else }} emptyDir: {} + {{- end -}} diff --git a/stable/mariadb/templates/pvc.yaml b/stable/mariadb/templates/pvc.yaml new file mode 100644 index 0000000000..db19bb97d9 --- /dev/null +++ b/stable/mariadb/templates/pvc.yaml @@ -0,0 +1,14 @@ +{{- if .Values.persistence.enabled }} +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{ template "fullname" . }} + annotations: + volume.alpha.kubernetes.io/storage-class: {{ .Values.persistence.storageClass | quote }} +spec: + accessModes: + - {{ .Values.persistence.accessMode | quote }} + resources: + requests: + storage: {{ .Values.persistence.size | quote }} +{{- end }} diff --git a/stable/mariadb/values.yaml b/stable/mariadb/values.yaml index d1e149f7d2..99eb03ed70 100644 --- a/stable/mariadb/values.yaml +++ b/stable/mariadb/values.yaml @@ -25,3 +25,10 @@ image: bitnami/mariadb:10.1.17-r1 ## ref: https://github.com/bitnami/bitnami-docker-mariadb/blob/master/README.md#creating-a-database-on-first-run ## # mariadbDatabase: + +## Persist data to a persitent volume +persistence: + enabled: true + storageClass: generic + accessMode: ReadWriteOnce + size: 8Gi