diff --git a/mariadb/.helmignore b/mariadb/.helmignore new file mode 100644 index 0000000000..6b8710a711 --- /dev/null +++ b/mariadb/.helmignore @@ -0,0 +1 @@ +.git diff --git a/mariadb/Chart.yaml b/mariadb/Chart.yaml new file mode 100644 index 0000000000..2f8e5ad1c5 --- /dev/null +++ b/mariadb/Chart.yaml @@ -0,0 +1,15 @@ +name: mariadb +version: 0.3.0 +description: Chart for MariaDB +keywords: +- mariadb +- mysql +- database +- sql +home: https://mariadb.org +sources: +- https://github.com/bitnami/bitnami-docker-mariadb +maintainers: +- name: Bitnami + email: containers@bitnami.com +engine: gotpl diff --git a/mariadb/README.md b/mariadb/README.md new file mode 100644 index 0000000000..fd0554c12a --- /dev/null +++ b/mariadb/README.md @@ -0,0 +1,122 @@ +# MariaDB + +[MariaDB](https://mariadb.org) is one of the most popular database servers in the world. It’s made by the original developers of MySQL and guaranteed to stay open source. Notable users include Wikipedia, Facebook and Google. + +MariaDB is developed as open source software and as a relational database it provides an SQL interface for accessing data. The latest versions of MariaDB also include GIS and JSON features. + +## TL;DR; + +```bash +$ helm install mariadb-x.x.x.tgz +``` + +## Introduction + +This chart bootstraps a [MariaDB](https://github.com/bitnami/bitnami-docker-mariadb) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager. + +## Get this chart + +Download the latest release of the chart from the [releases](../../../releases) page. + +Alternatively, clone the repo if you wish to use the development snapshot: + +```bash +$ git clone https://github.com/kubernetes/charts.git +``` + +## Installing the Chart + +To install the chart with the release name `my-release`: + +```bash +$ helm install --name my-release mariadb-x.x.x.tgz +``` + +*Replace the `x.x.x` placeholder with the chart release version.* + +The command deploys MariaDB on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation. + +> **Tip**: List all releases using `helm list` + +## Uninstalling the Chart + +To uninstall/delete the `my-release` deployment: + +```bash +$ helm delete my-release +``` + +The command removes all the Kubernetes components associated with the chart and deletes the release. + +## Configuration + +The following tables lists the configurable parameters of the MariaDB chart and their default values. + +| Parameter | Description | Default | +|-----------------------|----------------------------------|----------------------------------------------------------| +| `imageTag` | `bitnami/mariadb` image tag. | Most recent release | +| `imagePullPolicy` | Image pull policy. | `Always` if `imageTag` is `latest`, else `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` | + +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. + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, + +```bash +$ helm install --name my-release \ + --set mariadbRootPassword=secretpassword,mariadbUser=my-user,mariadbPassword=my-password,mariadbDatabase=my-database \ + mariadb-x.x.x.tgz +``` + +The above command sets the MariaDB `root` account password to `secretpassword`. Additionally it creates a standard database user named `my-user`, with the password `my-password`, who has access to a database named `my-database`. + +Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example, + +```bash +$ helm install --name my-release -f values.yaml mariadb-x.x.x.tgz +``` + +> **Tip**: You can use the default [values.yaml](values.yaml) + +## Persistence + +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. diff --git a/mariadb/templates/_helpers.tpl b/mariadb/templates/_helpers.tpl new file mode 100644 index 0000000000..dcbb49dcc8 --- /dev/null +++ b/mariadb/templates/_helpers.tpl @@ -0,0 +1,31 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 24 -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 24 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "fullname" -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- printf "%s-%s" .Release.Name $name | trunc 24 -}} +{{- end -}} + +{{/* +Get the imagePullPolicy. +*/}} +{{- define "imagePullPolicy" -}} + {{- if .Values.imagePullPolicy -}} + {{- .Values.imagePullPolicy -}} + {{- else -}} + {{- if eq .Values.imageTag "latest" -}} + {{- "Always" -}} + {{- else -}} + {{- "IfNotPresent" -}} + {{- end -}} + {{- end -}} +{{- end -}} diff --git a/mariadb/templates/deployment.yaml b/mariadb/templates/deployment.yaml new file mode 100644 index 0000000000..a86e9b5435 --- /dev/null +++ b/mariadb/templates/deployment.yaml @@ -0,0 +1,60 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ template "fullname" . }} + labels: + app: {{ template "fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +spec: + template: + metadata: + labels: + app: {{ template "fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" + spec: + containers: + - name: {{ template "fullname" . }} + image: "bitnami/mariadb:{{ .Values.imageTag }}" + imagePullPolicy: {{ template "imagePullPolicy" . }} + env: + - name: MARIADB_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: {{ template "fullname" . }} + key: mariadb-root-password + - name: MARIADB_USER + value: {{ default "" .Values.mariadbUser | quote }} + - name: MARIADB_PASSWORD + valueFrom: + secretKeyRef: + name: {{ template "fullname" . }} + key: mariadb-password + - name: MARIADB_DATABASE + value: {{ default "" .Values.mariadbDatabase | quote }} + ports: + - name: mysql + containerPort: 3306 + livenessProbe: + exec: + command: + - mysqladmin + - ping + initialDelaySeconds: 30 + timeoutSeconds: 5 + readinessProbe: + exec: + command: + - mysqladmin + - ping + initialDelaySeconds: 5 + timeoutSeconds: 1 + volumeMounts: + - name: data + mountPath: /bitnami/mariadb + volumes: + - name: data + emptyDir: {} diff --git a/mariadb/templates/secrets.yaml b/mariadb/templates/secrets.yaml new file mode 100644 index 0000000000..9c65480646 --- /dev/null +++ b/mariadb/templates/secrets.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ template "fullname" . }} + labels: + app: {{ template "fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +type: Opaque +data: + mariadb-root-password: {{ default "" .Values.mariadbRootPassword | b64enc | quote }} + mariadb-password: {{ default "" .Values.mariadbPassword | b64enc | quote }} diff --git a/mariadb/templates/svc.yaml b/mariadb/templates/svc.yaml new file mode 100644 index 0000000000..da71dfbc78 --- /dev/null +++ b/mariadb/templates/svc.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "fullname" . }} + labels: + app: {{ template "fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +spec: + ports: + - name: mysql + port: 3306 + targetPort: mysql + selector: + app: {{ template "fullname" . }} diff --git a/mariadb/values.yaml b/mariadb/values.yaml new file mode 100644 index 0000000000..864076e589 --- /dev/null +++ b/mariadb/values.yaml @@ -0,0 +1,27 @@ +## Bitnami MariaDB image version +## ref: https://hub.docker.com/r/bitnami/mariadb/tags/ +## +## Default: none +imageTag: 10.1.14-r3 + +## Specify a imagePullPolicy +## Default to 'Always' if imageTag is 'latest', else set to 'IfNotPresent' +## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images +## +# imagePullPolicy: + +## Specify password for root user +## ref: https://github.com/bitnami/bitnami-docker-mariadb/blob/master/README.md#setting-the-root-password-on-first-run +## +# mariadbRootPassword: + +## Create a database user +## ref: https://github.com/bitnami/bitnami-docker-mariadb/blob/master/README.md#creating-a-database-user-on-first-run +## +# mariadbUser: +# mariadbPassword: + +## Create a database +## ref: https://github.com/bitnami/bitnami-docker-mariadb/blob/master/README.md#creating-a-database-on-first-run +## +# mariadbDatabase: