diff --git a/vaultwarden/cronjob.yaml b/vaultwarden/cronjob.yaml new file mode 100644 index 0000000..bf82b93 --- /dev/null +++ b/vaultwarden/cronjob.yaml @@ -0,0 +1,25 @@ +apiVersion: batch/v1 +kind: CronJob +metadata: + name: backup-job + namespace: vaultwarden +spec: + schedule: "0 4 * * *" # Every day at 4AM + concurrencyPolicy: Forbid + jobTemplate: + spec: + template: + spec: + containers: + - name: maria-backup + image: mariadb + command: ["sh", "-c", "/usr/bin/mysqldump -h vaultwarden-svc.vaultwarden.svc.cluster.local -u root -pexample vaultwarden > /backup/vaultwarden/backup-$(date +'%H_%M-%d_%m_%Y').sql"] + volumeMounts: + - name: vaultwarden-backup + mountPath: /backup/vaultwarden + subPath: vaultwarden + volumes: + - name: vaultwarden-backup + persistentVolumeClaim: + claimName: vaultwarden-backup-pvc + restartPolicy: OnFailure diff --git a/vaultwarden/deployment.yaml b/vaultwarden/deployment.yaml index 816e11e..52c26fb 100644 --- a/vaultwarden/deployment.yaml +++ b/vaultwarden/deployment.yaml @@ -13,6 +13,8 @@ spec: labels: app: vaultwarden spec: + hostname: vaultwarden + subdomain: vaultwarden containers: - name: vaultwarden image: vaultwarden/server diff --git a/vaultwarden/pvc.yaml b/vaultwarden/pvc.yaml new file mode 100644 index 0000000..f9f7ff9 --- /dev/null +++ b/vaultwarden/pvc.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: vaultwarden-backup-pvc + namespace: vaultwarden +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi + storageClassName: flat-storage-class diff --git a/vaultwarden/service.yaml b/vaultwarden/service.yaml index 471c7aa..a651a30 100644 --- a/vaultwarden/service.yaml +++ b/vaultwarden/service.yaml @@ -9,5 +9,9 @@ spec: port: 80 protocol: TCP targetPort: 80 + - name: db + port: 3306 + protocol: TCP + targetPort: 3306 selector: app: vaultwarden