feat (molgenis-vault): Add backup cronjob
Needs to run under service account created by the etcd-operator subchart so there's some template magic needed to figure out what it's called.
This commit is contained in:
@ -1,3 +1,11 @@
|
||||
{{/* See https://github.com/helm/helm/issues/4535 */}}
|
||||
{{- define "call-nested" }}
|
||||
{{- $dot := index . 0 }}
|
||||
{{- $subchart := index . 1 }}
|
||||
{{- $template := index . 2 }}
|
||||
{{- include $template (dict "Chart" (dict "Name" $subchart) "Values" (index $dot.Values $subchart) "Release" $dot.Release "Capabilities" $dot.Capabilities) }}
|
||||
{{- end }}
|
||||
|
||||
{{/* vim: set filetype=mustache: */}}
|
||||
{{/*
|
||||
Expand the name of the chart.
|
||||
|
17
molgenis-vault/templates/backup-configmap.yaml
Normal file
17
molgenis-vault/templates/backup-configmap.yaml
Normal file
@ -0,0 +1,17 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: backup-config
|
||||
data:
|
||||
backup_cr.yaml: |
|
||||
apiVersion: "etcd.database.coreos.com/v1beta2"
|
||||
kind: "EtcdBackup"
|
||||
metadata:
|
||||
generateName: vault-backup-
|
||||
spec:
|
||||
etcdEndpoints: ["https://vault-etcd-client:2379"]
|
||||
storageType: ABS
|
||||
clientTLSSecret: vault-etcd-client-tls
|
||||
abs:
|
||||
path: vault/backup.<NOW>
|
||||
absSecret: abs
|
30
molgenis-vault/templates/backup-cronjob.yaml
Normal file
30
molgenis-vault/templates/backup-cronjob.yaml
Normal file
@ -0,0 +1,30 @@
|
||||
{{- if .Values.backupJob.enable }}
|
||||
# cronjob that creates etcdbackups using the etcd backup serviceaccount
|
||||
apiVersion: batch/v1beta1
|
||||
kind: CronJob
|
||||
metadata:
|
||||
name: etcd-backup
|
||||
spec:
|
||||
schedule: {{ .Values.backupJob.schedule | quote }}
|
||||
jobTemplate:
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
serviceAccountName: {{ include "call-nested" (list . "etcd-operator" "etcd-operator.serviceAccountName") }}
|
||||
containers:
|
||||
- name: etcd-backup
|
||||
image: lachlanevenson/k8s-kubectl
|
||||
command:
|
||||
- /bin/sh
|
||||
- "-ec"
|
||||
- |
|
||||
sed -e "s|<NOW>|$(date '+%Y-%m-%d_%H:%M:%S')|g" /var/etcd_backup/backup_cr.yaml | kubectl create -f -
|
||||
volumeMounts:
|
||||
- name: backup-config
|
||||
mountPath: /var/etcd_backup
|
||||
restartPolicy: OnFailure
|
||||
volumes:
|
||||
- name: backup-config
|
||||
configMap:
|
||||
name: backup-config
|
||||
{{- end }}
|
Reference in New Issue
Block a user