Skip to content

Commit 5f686a4

Browse files
committed
Helm Chart for MariaDB
1 parent 541d7a3 commit 5f686a4

File tree

10 files changed

+584
-0
lines changed

10 files changed

+584
-0
lines changed

charts/mariadb/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

charts/mariadb/Chart.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v2
2+
name: mariadb
3+
description: Helm chart for MariaDB on K8s
4+
5+
type: application
6+
7+
maintainers:
8+
- name: alokjani
9+
10+
version: 10.5.12
11+
12+
appVersion: "10.5.12"

charts/mariadb/README.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# MariaDB
2+
3+
![Version: 10.5.12](https://img.shields.io/badge/Version-10.5.12-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 10.5.12](https://img.shields.io/badge/AppVersion-10.5.12-informational?style=flat-square)
4+
5+
A Helm chart for MariaDB on Kubernetes
6+
7+
## TL;DR
8+
9+
```bash
10+
$ helm repo add alokjani https://alokjani.github.io/helm-charts/
11+
$ helm install my-release alokjani/mariadb
12+
```
13+
14+
## Introduction
15+
16+
This chart uses the original [MariaDB image from Docker Hub](https://hub.docker.com/_/mariadb) to deploy a stateful MariaDB instance in a Kubernetes cluster.
17+
18+
It fully supports deployment of the multi-architecture docker image.
19+
20+
## Prerequisites
21+
22+
- Kubernetes 1.12+
23+
- Helm 3.x
24+
- PV provisioner support in the underlying infrastructure
25+
26+
## Installing the Chart
27+
28+
To install the chart with the release name `my-release`:
29+
30+
```bash
31+
$ helm install my-release alokjani/mariadb
32+
```
33+
34+
## Uninstalling the Chart
35+
36+
To uninstall/delete the `my-release` deployment:
37+
38+
```bash
39+
$ helm uninstall my-release
40+
```
41+
42+
## Common parameters
43+
44+
| Key | Type | Default | Description |
45+
|-----|------|---------|-------------|
46+
| fullnameOverride | string | `""` | Fully override the deployment name |
47+
| nameOverride | string | `""` | Partially override the deployment name |
48+
49+
## Deployment parameters
50+
51+
| Key | Type | Default | Description |
52+
|-----|------|---------|-------------|
53+
| image.pullPolicy | string | `"IfNotPresent"` | Image pull policy |
54+
| image.repository | string | `"mariadb"` | Image name |
55+
| image.tag | string | `""` | Image tag |
56+
| imagePullSecrets | list | `[]` | Image pull secrets |
57+
| livenessProbe | object | `see values.yaml` | Liveness probe configuration |
58+
| readinessProbe | object | `see values.yaml` | Readiness probe configuration |
59+
| customLivenessProbe | object | `{}` | Custom liveness probe (overwrites default liveness probe configuration) |
60+
| customReadinessProbe | object | `{}` | Custom readiness probe (overwrites default readiness probe configuration) |
61+
| resources | object | `{}` | Resource limits and requests |
62+
| nodeSelector | object | `{}` | Deployment node selector |
63+
| podAnnotations | object | `{}` | Additional pod annotations |
64+
| podSecurityContext | object | `see values.yaml` | Pod security context |
65+
| securityContext | object | `see values.yaml` | Container security context |
66+
| env | list | `[]` | Additional container environmment variables |
67+
| serviceAccount.annotations | object | `{}` | Additional service account annotations |
68+
| serviceAccount.create | bool | `false` | Enable service account creation |
69+
| serviceAccount.name | string | `""` | Name of the service account |
70+
| affinity | object | `{}` | Affinity for pod assignment |
71+
| tolerations | list | `[]` | Tolerations for pod assignment |
72+
| podManagementPolicy | string | `"OrderedReady"` | Pod management policy |
73+
| updateStrategyType | string | `"RollingUpdate"` | Pod update strategy |
74+
| revisionHistoryLimit | int | `nil` | Maximum number of revisions maintained in revision history
75+
76+
## Service paramters
77+
78+
| Key | Type | Default | Description |
79+
|-----|------|---------|-------------|
80+
| service.type | string | `"ClusterIP"` | Service type |
81+
| service.port | int | `3306` | MariaDB service port |
82+
| service.nodePort | int | `nil` | The node port (only relevant for type LoadBalancer or NodePort) |
83+
| service.clusterIP | string | `nil` | The cluster ip address (only relevant for type LoadBalancer or NodePort) |
84+
| service.loadBalancerIP | string | `nil` | The load balancer ip address (only relevant for type LoadBalancer) |
85+
86+
## Storage parameters
87+
88+
| Key | Type | Default | Description |
89+
|-----|------|---------|-------------|
90+
| storage.accessModes[0] | string | `"ReadWriteOnce"` | Storage access mode |
91+
| storage.persistentVolumeClaimName | string | `nil` | PVC name when existing storage volume should be used |
92+
| storage.requestedSize | string | `nil` | Size for new PVC, when no existing PVC is used |
93+
| storage.className | string | `nil` | Storage class name |
94+
95+
## MariaDB parameters
96+
97+
| Key | Type | Default | Description |
98+
|-----|------|---------|-------------|
99+
| userDatabase | object | `{}` | Optional MariaDB user database |
100+
| userDatabase.name | string | `""` | Name of the user database |
101+
| userDatabase.user | string | `""` | User name with full access to user database|
102+
| userDatabase.password | string | `""` | Password of created user (Random value if not specified) |
103+
| settings.rootPassword | string | `nil` | MariaDB root password (Random value if not specified) |
104+
| settings.arguments | list | `[]` | Additional arguments for mysqld (entrypoint process) |
105+
| customConfig | string | `nil` | Additional MariaDB custom configuration mounted as custom.cnf |
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "mariadb.name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
7+
{{- end }}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12+
If release name contains chart name it will be used as a full name.
13+
*/}}
14+
{{- define "mariadb.fullname" -}}
15+
{{- if .Values.fullnameOverride }}
16+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
17+
{{- else }}
18+
{{- $name := default .Chart.Name .Values.nameOverride }}
19+
{{- if contains $name .Release.Name }}
20+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
21+
{{- else }}
22+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
23+
{{- end }}
24+
{{- end }}
25+
{{- end }}
26+
27+
{{/*
28+
Create chart name and version as used by the chart label.
29+
*/}}
30+
{{- define "mariadb.chart" -}}
31+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
32+
{{- end }}
33+
34+
{{/*
35+
Common labels
36+
*/}}
37+
{{- define "mariadb.labels" -}}
38+
helm.sh/chart: {{ include "mariadb.chart" . }}
39+
{{ include "mariadb.selectorLabels" . }}
40+
{{- if .Chart.AppVersion }}
41+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
42+
{{- end }}
43+
app.kubernetes.io/managed-by: {{ .Release.Service }}
44+
{{- end }}
45+
46+
{{/*
47+
Selector labels
48+
*/}}
49+
{{- define "mariadb.selectorLabels" -}}
50+
app.kubernetes.io/name: {{ include "mariadb.name" . }}
51+
app.kubernetes.io/instance: {{ .Release.Name }}
52+
{{- end }}
53+
54+
{{/*
55+
Create the name of the service account to use
56+
*/}}
57+
{{- define "mariadb.serviceAccountName" -}}
58+
{{- if .Values.serviceAccount.create }}
59+
{{- default (include "mariadb.fullname" .) .Values.serviceAccount.name }}
60+
{{- else }}
61+
{{- default "default" .Values.serviceAccount.name }}
62+
{{- end }}
63+
{{- end }}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{{- if .Values.customConfig }}
2+
kind: ConfigMap
3+
apiVersion: v1
4+
metadata:
5+
name: {{ include "mariadb.fullname" . }}
6+
labels:
7+
{{- include "mariadb.labels" . | nindent 4 }}
8+
data:
9+
custom.cnf: |-
10+
{{- .Values.customConfig | nindent 4 }}
11+
{{- end }}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{{- $existingRootPassword := "" }}
2+
{{- $existingUserDbName := "" }}
3+
{{- $existingUserDbUser := "" }}
4+
{{- $existingUserDbPassword := "" }}
5+
{{- $secret := (lookup "v1" "Secret" .Release.Namespace (include "mariadb.fullname" .) ) }}
6+
{{- if $secret }}
7+
{{- $existingRootPassword = index $secret.data "MYSQL_ROOT_PASSWORD" }}
8+
{{- $existingUserDbName = index $secret.data "MYSQL_DATABASE" }}
9+
{{- $existingUserDbUser = index $secret.data "MYSQL_USER" }}
10+
{{- $existingUserDbPassword = index $secret.data "MYSQL_PASSWORD" }}
11+
{{- end -}}
12+
apiVersion: v1
13+
kind: Secret
14+
metadata:
15+
name: {{ include "mariadb.fullname" . }}
16+
labels:
17+
{{- include "mariadb.labels" . | nindent 4 }}
18+
type: Opaque
19+
data:
20+
{{- $rootPassword := coalesce (.Values.settings.rootPassword | default "" | b64enc) $existingRootPassword (randAlphaNum 10 | b64enc) }}
21+
MYSQL_ROOT_PASSWORD: {{ $rootPassword }}
22+
{{- with .Values.userDatabase }}
23+
{{- $userDbName := coalesce (.name | default "" | b64enc) $existingUserDbName }}
24+
{{- $userDbUser := coalesce (.user | default "" | b64enc) $existingUserDbUser }}
25+
MYSQL_DATABASE: {{ required "Values: userDatabase.name is mandatory if userDatabase is specified." $userDbName }}
26+
MYSQL_USER: {{ required "Values: userDatabase.user is mandatory if userDatabase is specified." $userDbUser }}
27+
MYSQL_PASSWORD: {{ coalesce (.password | default "" | b64enc) $existingUserDbPassword (randAlphaNum 10 | b64enc) }}
28+
{{- end }}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "mariadb.fullname" . }}
5+
labels:
6+
{{- include "mariadb.labels" . | nindent 4 }}
7+
spec:
8+
type: {{ .Values.service.type }}
9+
ports:
10+
- port: {{ .Values.service.port }}
11+
targetPort: sql
12+
protocol: TCP
13+
name: sql
14+
{{- if and ( or (eq .Values.service.type "LoadBalancer") (eq .Values.service.type "NodePort") ) (.Values.service.nodePort) }}
15+
nodePort: {{ .Values.service.nodePort }}
16+
{{- end }}
17+
{{- if and (eq .Values.service.type "LoadBalancer") (.Values.service.loadBalancerIP) }}
18+
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
19+
{{- end }}
20+
{{- if .Values.service.clusterIP }}
21+
clusterIP: {{ .Values.service.clusterIP }}
22+
{{- end }}
23+
selector:
24+
{{- include "mariadb.selectorLabels" . | nindent 4 }}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{{- if .Values.serviceAccount.create -}}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: {{ include "mariadb.serviceAccountName" . }}
6+
labels:
7+
{{- include "mariadb.labels" . | nindent 4 }}
8+
{{- with .Values.serviceAccount.annotations }}
9+
annotations:
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
{{- end }}

0 commit comments

Comments
 (0)