Added zammad-backup und s3 sync

This commit is contained in:
Kersten Burkhardt 2017-10-24 22:42:40 +02:00
parent 3efca6cd8b
commit 5a8fbbd8e0
6 changed files with 136 additions and 1 deletions

View File

@ -34,6 +34,20 @@ metadata:
namespace: zammad
annotations:
volume.beta.kubernetes.io/storage-class: standard
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 10G
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: zammad-backup
namespace: zammad
annotations:
volume.beta.kubernetes.io/storage-class: standard
spec:
accessModes:
- ReadWriteMany

View File

@ -0,0 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: zammad-backup
namespace: zammad
data:
S3_PATH: s3://BUCKET_NAME/

View File

@ -0,0 +1,9 @@
apiVersion: v1
kind: Secret
metadata:
name: zammad-backup-s3
namespace: zammad
type: Opaque
data:
ACCESS_KEY: 'bash ACCESS_KEY | base64'
SECRET_KEY: 'bash SECRET_KEY | base64'

View File

@ -0,0 +1,38 @@
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: zammad-backup
namespace: zammad
labels:
component: backup
app: zammad
spec:
serviceName: zammad-backup
replicas: 1
template:
metadata:
labels:
component: backup
app: zammad
spec:
terminationGracePeriodSeconds: 10
volumes:
- name: zammad-home
persistentVolumeClaim:
claimName: zammad-home
- name: zammad-backup
persistentVolumeClaim:
claimName: zammad-backup
containers:
- name: zammad-backup
image: zammad/zammad-docker-compose:zammad-postgresql
command:
- /usr/local/bin/backup.sh
args:
- zammad-backup
imagePullPolicy: Always
volumeMounts:
- mountPath: /home/zammad
name: zammad-home
- mountPath: /var/tmp/zammad
name: zammad-backup

View File

@ -0,0 +1,51 @@
---
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: zammad-backup
namespace: zammad
labels:
component: cronjob
app: backup
spec:
failedJobsHistoryLimit: 0
successfulJobsHistoryLimit: 0
concurrencyPolicy: Forbid
schedule: "0 0 * * *"
jobTemplate:
spec:
template:
metadata:
labels:
component: cronjob
app: backup
spec:
volumes:
- name: zammad-backup
persistentVolumeClaim:
claimName: zammad-backup
containers:
- name: zammad-backup-s3
imagePullPolicy: Always
image: robbydooo/docker-backup-to-s3
args:
- "/start.sh"
- "no-cron"
envFrom:
- configMapRef:
name: zammad-backup
env:
- name: ACCESS_KEY
valueFrom:
secretKeyRef:
name: zammad-backup-s3
key: ACCESS_KEY
- name: SECRET_KEY
valueFrom:
secretKeyRef:
name: zammad-backup-s3
key: SECRET_KEY
volumeMounts:
- mountPath: /data
name: zammad-backup
restartPolicy: OnFailure

View File

@ -4,4 +4,20 @@
- On every node you need to set `sysctl -w vm.max_map_count=262144`
- Change the ingress to your needs.
- Hit `kubectl apply -f ./` and wait till everything is setup.
## Amazon S3 Backup
If you want to be synced with a S3 bucket, then just fill the `30_secret_backup.yaml` with your secret and access keys.
```bash
echo -n "ACCESS_KEY" | base64
echo -n "SECRET_KEY" | base64
```
Change the bucket path in the `20_configmap_backup.yaml`.
That's it.
## Deploy zammad
Hit `kubectl apply -f ./` and wait till everything is setup.