Skip to content

Commit b7394ff

Browse files
authored
Merge pull request #4 from vshn/mariadb/backup
Add backup option for mariadb instances
2 parents f5d1937 + d99c8f8 commit b7394ff

File tree

8 files changed

+94
-5
lines changed

8 files changed

+94
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ helm repo add appcat https://charts.appcat.ch
1515

1616
| Downloads & Changelog | Chart |
1717
| --- | --- |
18-
| [![chart downloads](https://img.shields.io/github/downloads/vshn/appcat-charts/vshnmariadb-0.0.3/total)](https://github.com/vshn/appcat-charts/releases/tag/vshnmariadb-0.0.3) | [vshnmariadb](charts/vshnmariadb/README.md) |
18+
| [![chart downloads](https://img.shields.io/github/downloads/vshn/appcat-charts/vshnmariadb-0.0.4/total)](https://github.com/vshn/appcat-charts/releases/tag/vshnmariadb-0.0.4) | [vshnmariadb](charts/vshnmariadb/README.md) |
1919

2020
## Add / Update Charts
2121

charts/vshnmariadb/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
apiVersion: v1
2-
appVersion: 0.0.3
2+
appVersion: 0.0.4
33
description: A Helm chart for MariaDB instances using the mariadb-operator
44
name: vshnmariadb
5-
version: 0.0.3
5+
version: 0.0.4
66
maintainers:
77
- name: Schedar Team
88
email: info@vshn.ch

charts/vshnmariadb/README.gotmpl.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Only MariaDB official images are supported. |
2222
| `storage.size` | PVC size of the instance | 1Gi
2323
| `resources` | Resources describes the compute resource requirements. |
2424
| `rootPasswordSecretKeyRef` | Reference to the secret containing the root password |
25+
| `affinity` | Definites the affinity for the pods |
2526

2627
### Galera
2728

@@ -37,3 +38,13 @@ Only MariaDB official images are supported. |
3738
| --- | --- | ---
3839
| `metrics.enabled` | Enabled is a flag to enable Metrics | true
3940
| `exporter.image` | Image name to be used as metrics exporter. The supported format is <image>:<tag>. |
41+
42+
### Backup
43+
44+
| Parameter | Description | Default
45+
| --- | --- | ---
46+
| `backup.enabled` | Enabled is a flag to enable backups | false
47+
| `backup.s3.bucket` | Name of the s3 bucket for the backups |
48+
| `backup.s3.endpoint` | Name of the s3 endpoint for the backups |
49+
| `backup.s3.accessKey` | Access key for the s3 bucket |
50+
| `backup.s3.secretKey` | Secret key for the s3 bucket |

charts/vshnmariadb/README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# vshnmariadb
22

3-
![Version: 0.0.3](https://img.shields.io/badge/Version-0.0.3-informational?style=flat-square) ![AppVersion: 0.0.3](https://img.shields.io/badge/AppVersion-0.0.3-informational?style=flat-square)
3+
![Version: 0.0.4](https://img.shields.io/badge/Version-0.0.4-informational?style=flat-square) ![AppVersion: 0.0.4](https://img.shields.io/badge/AppVersion-0.0.4-informational?style=flat-square)
44

55
A Helm chart for MariaDB instances using the mariadb-operator
66

@@ -34,6 +34,7 @@ Only MariaDB official images are supported. |
3434
| `storage.size` | PVC size of the instance | 1Gi
3535
| `resources` | Resources describes the compute resource requirements. |
3636
| `rootPasswordSecretKeyRef` | Reference to the secret containing the root password |
37+
| `affinity` | Definites the affinity for the pods |
3738

3839
### Galera
3940

@@ -50,6 +51,16 @@ Only MariaDB official images are supported. |
5051
| `metrics.enabled` | Enabled is a flag to enable Metrics | true
5152
| `exporter.image` | Image name to be used as metrics exporter. The supported format is <image>:<tag>. |
5253

54+
### Backup
55+
56+
| Parameter | Description | Default
57+
| --- | --- | ---
58+
| `backup.enabled` | Enabled is a flag to enable backups | false
59+
| `backup.s3.bucket` | Name of the s3 bucket for the backups |
60+
| `backup.s3.endpoint` | Name of the s3 endpoint for the backups |
61+
| `backup.s3.accessKey` | Access key for the s3 bucket |
62+
| `backup.s3.secretKey` | Secret key for the s3 bucket |
63+
5364
<!---
5465
Common/Useful Link references from values.yaml
5566
-->
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{{- if .Values.backup.enabled -}}
2+
apiVersion: k8s.mariadb.com/v1alpha1
3+
kind: PhysicalBackup
4+
metadata:
5+
name: {{ include "mariadb.fullname" . }}
6+
labels:
7+
app.kubernetes.io/name: {{ include "mariadb.name" . }}
8+
helm.sh/chart: {{ include "mariadb.chart" . }}
9+
app.kubernetes.io/instance: {{ .Release.Name }}
10+
app.kubernetes.io/managed-by: {{ .Release.Service }}
11+
spec:
12+
mariaDbRef:
13+
name: {{ include "mariadb.fullname" . }}
14+
storage:
15+
schedule:
16+
{{/* Generate uniform random minute (0–59) */}}
17+
{{- $minute := (randNumeric 2 | atoi) -}}
18+
{{- if gt $minute 59 -}}{{- $minute = (mod $minute 60) -}}{{- end -}}
19+
20+
{{/* Random index 0–7 */}}
21+
{{- $r := (mod (atoi (randNumeric 2)) 8) -}}
22+
23+
{{/* Allowed night hours */}}
24+
{{- $nightHours := list 22 23 0 1 2 3 4 5 -}}
25+
26+
{{- $hour := index $nightHours $r -}}
27+
cron: {{ printf "%d %d * * *" $minute $hour }}
28+
s3:
29+
bucket: {{ .Values.backup.s3.bucket }}
30+
endpoint: {{ .Values.backup.s3.endpoint }}
31+
accessKeyIdSecretKeyRef:
32+
name: backup
33+
key: access-key
34+
secretAccessKeySecretKeyRef:
35+
name: backup
36+
key: secret-key
37+
tls:
38+
enabled: true
39+
stagingStorage:
40+
persistentVolumeClaim:
41+
resources:
42+
requests:
43+
storage: {{ .Values.storage.size }}
44+
accessModes:
45+
- ReadWriteOnce
46+
{{- end -}}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{{- if .Values.backup.enabled -}}
2+
apiVersion: v1
3+
kind: Secret
4+
metadata:
5+
name: backup
6+
namespace: {{ .Release.Namespace | quote }}
7+
labels:
8+
app.kubernetes.io/name: {{ include "mariadb.name" . }}
9+
helm.sh/chart: {{ include "mariadb.chart" . }}
10+
app.kubernetes.io/instance: {{ .Release.Name }}
11+
app.kubernetes.io/managed-by: {{ .Release.Service }}
12+
type: Opaque
13+
data:
14+
access-key: {{ .Values.backup.s3.accessKey | b64enc | quote }}
15+
secret-key: {{ .Values.backup.s3.secretKey | b64enc | quote }}
16+
{{- end -}}

charts/vshnmariadb/templates/mariadb.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ metadata:
77
helm.sh/chart: {{ include "mariadb.chart" . }}
88
app.kubernetes.io/instance: {{ .Release.Name }}
99
app.kubernetes.io/managed-by: {{ .Release.Service }}
10-
1110
spec:
1211
{{ if .Values.rootPasswordSecretKeyRef}}
1312
rootPasswordSecretKeyRef: {{ .Values.rootPasswordSecretKeyRef | toYaml | nindent 4 }}
@@ -35,4 +34,7 @@ spec:
3534
{{- end }}
3635
storage:
3736
size: {{ .Values.storage.size }}
37+
{{- with .Values.affinity }}
38+
affinity: {{ . | toYaml | nindent 4 }}
39+
{{- end }}
3840

charts/vshnmariadb/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ metrics:
2020
enabled: true
2121
exporter:
2222
image: nil
23+
24+
backup:
25+
enabled: false

0 commit comments

Comments
 (0)