mirror of
https://github.com/bitnami/charts.git
synced 2026-03-13 14:57:24 +08:00
Merge pull request #71 from sameersbn/T12650
mariadb: converts to deployment object and uses helper templates
This commit is contained in:
@@ -0,0 +1 @@
|
||||
.git
|
||||
|
||||
@@ -1,37 +1,126 @@
|
||||
# MariaDB
|
||||
|
||||
> MariaDB is a 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.
|
||||
[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.
|
||||
|
||||
Based on the [Bitnami MariaDB](https://github.com/bitnami/bitnami-docker-mariadb) image for docker, this Chart bootstraps a [MariaDB](https://mariadb.com/) deployment on a [Kubernetes](http://kubernetes.io) cluster using [Helm](https://helm.sh).
|
||||
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.
|
||||
|
||||
## Persistence
|
||||
[source](https://mariadb.org/about/)
|
||||
|
||||
For persistence of the MariaDB data, mount a [storage volume](http://kubernetes.io/docs/user-guide/volumes/) at the `/bitnami/mariadb` path of the MariaDB pod.
|
||||
## TL;DR;
|
||||
|
||||
By default the MariaDB Chart mounts an [emptyDir](http://kubernetes.io/docs/user-guide/volumes/#emptydir) volume.
|
||||
```bash
|
||||
$ helm install mariadb-x.x.x.tgz
|
||||
```
|
||||
|
||||
## Introduction
|
||||
|
||||
Bitnami charts for Helm are carefully engineered, actively maintained and are the quickest and easiest way to deploy containers, on a Kubernetes cluster, that are ready to handle production workloads.
|
||||
|
||||
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/bitnami/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
|
||||
|
||||
To edit the default MariaDB configuration, run
|
||||
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
|
||||
$ helmc edit mariadb
|
||||
$ helm install --name my-release \
|
||||
--set mariadbRootPassword=secretpassword,mariadbUser=my-user,mariadbPassword=my-password,mariadbDatabase=my-database \
|
||||
mariadb-x.x.x.tgz
|
||||
```
|
||||
|
||||
Configurable parameters can be specified in `tpl/values.toml`. If not specified default values as defined by the [Bitnami MariaDB](https://github.com/bitnami/bitnami-docker-mariadb) image are used.
|
||||
The above command set 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`.
|
||||
|
||||
> Tip: If you have issues running the above command, add `se autochdir` to your `~/.vimrc` profile or simply edit `~/.helmc/workspace/charts/mariadb/tpl/values.toml` in your favourite editor.
|
||||
|
||||
Finally, generate the chart to apply your changes to the configuration.
|
||||
Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example,
|
||||
|
||||
```bash
|
||||
$ helmc generate --force mariadb
|
||||
$ helm install --name my-release -f values.yaml mariadb-x.x.x.tgz
|
||||
```
|
||||
|
||||
## Cleanup
|
||||
> **Tip**: You can use the default [values.yaml](values.yaml)
|
||||
|
||||
To delete the MariaDB deployment completely:
|
||||
## 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
|
||||
$ helmc uninstall -n default mariadb
|
||||
$ 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.
|
||||
|
||||
31
mariadb/templates/_helpers.tpl
Normal file
31
mariadb/templates/_helpers.tpl
Normal file
@@ -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 -}}
|
||||
@@ -1,40 +1,37 @@
|
||||
apiVersion: v1
|
||||
kind: ReplicationController
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ printf "%s-%s" .Release.Name "mariadb" | trunc 24 }}
|
||||
name: {{ template "fullname" . }}
|
||||
labels:
|
||||
provider: mariadb
|
||||
release: {{ .Release.Name }}
|
||||
heritage: bitnami
|
||||
app: {{ template "fullname" . }}
|
||||
chart: "{{ .Chart.Name }}-{{ .Chart.Name }}"
|
||||
release: "{{ .Release.Name }}"
|
||||
heritage: "{{ .Release.Service }}"
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
provider: mariadb
|
||||
release: {{ .Release.Name }}
|
||||
version: {{ .Values.imageTag }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
provider: mariadb
|
||||
release: {{ .Release.Name }}
|
||||
version: {{ .Values.imageTag }}
|
||||
heritage: bitnami
|
||||
app: {{ template "fullname" . }}
|
||||
chart: "{{ .Chart.Name }}-{{ .Chart.Name }}"
|
||||
release: "{{ .Release.Name }}"
|
||||
heritage: "{{ .Release.Service }}"
|
||||
spec:
|
||||
containers:
|
||||
- name: mariadb
|
||||
image: bitnami/mariadb:{{ .Values.imageTag }}
|
||||
- name: {{ template "fullname" . }}
|
||||
image: "bitnami/mariadb:{{ .Values.imageTag }}"
|
||||
imagePullPolicy: {{ template "imagePullPolicy" . }}
|
||||
env:
|
||||
- name: MARIADB_ROOT_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ printf "%s-%s" .Release.Name "mariadb" | trunc 24 }}
|
||||
name: {{ template "fullname" . }}
|
||||
key: mariadb-root-password
|
||||
- name: MARIADB_USER
|
||||
value: {{ default "" .Values.mariadbUser | quote }}
|
||||
- name: MARIADB_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ printf "%s-%s" .Release.Name "mariadb" | trunc 24 }}
|
||||
name: {{ template "fullname" . }}
|
||||
key: mariadb-password
|
||||
- name: MARIADB_DATABASE
|
||||
value: {{ default "" .Values.mariadbDatabase | quote }}
|
||||
@@ -1,16 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ printf "%s-%s" .Release.Name "mariadb" | trunc 24 }}
|
||||
labels:
|
||||
provider: mariadb
|
||||
release: {{ .Release.Name }}
|
||||
heritage: bitnami
|
||||
spec:
|
||||
ports:
|
||||
- name: mysql
|
||||
port: 3306
|
||||
targetPort: mysql
|
||||
selector:
|
||||
provider: mariadb
|
||||
release: {{ .Release.Name }}
|
||||
@@ -1,11 +1,12 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: {{ printf "%s-%s" .Release.Name "mariadb" | trunc 24 }}
|
||||
name: {{ template "fullname" . }}
|
||||
labels:
|
||||
provider: mariadb
|
||||
release: {{ .Release.Name }}
|
||||
heritage: bitnami
|
||||
app: {{ template "fullname" . }}
|
||||
chart: "{{ .Chart.Name }}-{{ .Chart.Name }}"
|
||||
release: "{{ .Release.Name }}"
|
||||
heritage: "{{ .Release.Service }}"
|
||||
type: Opaque
|
||||
data:
|
||||
mariadb-root-password: {{ default "" .Values.mariadbRootPassword | b64enc | quote }}
|
||||
16
mariadb/templates/svc.yaml
Normal file
16
mariadb/templates/svc.yaml
Normal file
@@ -0,0 +1,16 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ template "fullname" . }}
|
||||
labels:
|
||||
app: {{ template "fullname" . }}
|
||||
chart: "{{ .Chart.Name }}-{{ .Chart.Name }}"
|
||||
release: "{{ .Release.Name }}"
|
||||
heritage: "{{ .Release.Service }}"
|
||||
spec:
|
||||
ports:
|
||||
- name: mysql
|
||||
port: 3306
|
||||
targetPort: mysql
|
||||
selector:
|
||||
app: {{ template "fullname" . }}
|
||||
@@ -1,6 +1,27 @@
|
||||
imageTag: 10.1.14-r1
|
||||
## Bitnami MariaDB image version
|
||||
## ref: https://hub.docker.com/r/bitnami/mariadb/tags/
|
||||
##
|
||||
## Default: none
|
||||
imageTag: 10.1.14-r2
|
||||
|
||||
mariadbRootPassword:
|
||||
mariadbUser:
|
||||
mariadbPassword:
|
||||
mariadbDatabase:
|
||||
## 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:
|
||||
|
||||
Reference in New Issue
Block a user