using kustomization for deploy
This commit is contained in:
129
deploy/app/cronjobs/backup-cronjob.yaml
Normal file
129
deploy/app/cronjobs/backup-cronjob.yaml
Normal file
@@ -0,0 +1,129 @@
|
||||
apiVersion: batch/v1
|
||||
kind: CronJob
|
||||
metadata:
|
||||
name: backup
|
||||
namespace: cloud-limbosolutions-com
|
||||
spec:
|
||||
schedule: "0 2 * * *"
|
||||
jobTemplate:
|
||||
spec:
|
||||
backoffLimit: 1
|
||||
template:
|
||||
spec:
|
||||
restartPolicy: Never
|
||||
initContainers:
|
||||
- name: mariadb-client
|
||||
resources:
|
||||
limits:
|
||||
memory: "512Mi"
|
||||
cpu: "500m"
|
||||
requests:
|
||||
memory: "256Mi"
|
||||
cpu: "250m"
|
||||
image: alpine/mysql
|
||||
command: ["sh", "-c"]
|
||||
args:
|
||||
- |
|
||||
set -e
|
||||
mkdir -p /data/mariadb-export
|
||||
echo "TRACE: Exporting database"
|
||||
#mysqldump --column-statistics=0 -u ${MYSQL_USER} -h ${MYSQL_HOST} ${MYSQL_DB} > /data/mariadb-export/backup.sql
|
||||
mysqldump -u ${MYSQL_USER} -h ${MYSQL_HOST} ${MYSQL_DB} > /data/mariadb-export/backup.sql
|
||||
echo "TRACE: Exporting database finished"
|
||||
|
||||
env:
|
||||
- name: MYSQL_USER
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: nextcloud-db
|
||||
key: db-username
|
||||
|
||||
- name: MYSQL_PWD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: nextcloud-db
|
||||
key: db-password
|
||||
|
||||
- name: MYSQL_DB
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: backup-secret
|
||||
key: DB_NAME
|
||||
|
||||
- name: MYSQL_HOST
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: backup-secret
|
||||
key: DB_HOST
|
||||
|
||||
volumeMounts:
|
||||
- name: backup-var
|
||||
mountPath: /data/mariadb-export
|
||||
subPath: mariadb-export
|
||||
|
||||
|
||||
containers:
|
||||
- name: gitea-pbs-client
|
||||
image: git.limbosolutions.com/kb/pbsclient
|
||||
env:
|
||||
- name: MODE
|
||||
value: shell
|
||||
- name: PBS_REPOSITORY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: backup-secret
|
||||
key: PBS_REPOSITORY
|
||||
- name: PBS_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: backup-secret
|
||||
key: PBS_PASSWORD
|
||||
- name: PBS_FINGERPRINT
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: backup-secret
|
||||
key: PBS_FINGERPRINT
|
||||
|
||||
command: ["bash", "-c"]
|
||||
args:
|
||||
- |
|
||||
set -e
|
||||
SCRIPT_START_TIME=$(date +%s)
|
||||
proxmox-backup-client backup nextcloud-html.pxar:/data/nextcloud-html nextcloud-data.pxar:/data/nextcloud-data mariadb-data.pxar:/data/mariadb-data mariadb-export.pxar:/data/mariadb-export --include-dev /data/nextcloud-html --include-dev /data/nextcloud-data --include-dev /data/mariadb-data --include-dev /data/mariadb-export --backup-id "nextcloud-full" -ns cloud.limbosolutions.com && \
|
||||
SCRIPT_DURATION=$(($(date +%s) - SCRIPT_START_TIME)) && \
|
||||
echo "INFO: Finished Backup of cloud.limbosolutions.com ($((SCRIPT_DURATION / 60 / 60)):$((SCRIPT_DURATION / 60)):$((SCRIPT_DURATION % 60)))"
|
||||
|
||||
volumeMounts:
|
||||
- name: nextcloud-html
|
||||
mountPath: /data/nextcloud-html
|
||||
|
||||
- name: nextcloud-data
|
||||
mountPath: /data/nextcloud-data
|
||||
|
||||
- name: db-data
|
||||
mountPath: /data/mariadb-data
|
||||
|
||||
- name: backup-var
|
||||
mountPath: /tmp
|
||||
subPath: tmp
|
||||
|
||||
- name: backup-var
|
||||
mountPath: /data/mariadb-export
|
||||
subPath: mariadb-export
|
||||
|
||||
volumes:
|
||||
- name: nextcloud-html
|
||||
persistentVolumeClaim:
|
||||
claimName: nextcloud-nextcloud
|
||||
|
||||
- name: nextcloud-data
|
||||
persistentVolumeClaim:
|
||||
claimName: nextcloud-nextcloud-data
|
||||
|
||||
- name: db-data
|
||||
persistentVolumeClaim:
|
||||
claimName: data-nextcloud-mariadb-0
|
||||
|
||||
- name: backup-var
|
||||
emptyDir: {}
|
||||
|
||||
112
deploy/app/cronjobs/persistance-volumes-claims.yaml
Normal file
112
deploy/app/cronjobs/persistance-volumes-claims.yaml
Normal file
@@ -0,0 +1,112 @@
|
||||
|
||||
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: mf-documents-storage-limbosolutions-com
|
||||
namespace: cloud-limbosolutions-com
|
||||
spec:
|
||||
storageClassName: "" # isto tem mesmo de ficar senão não funciona não sei pq.. tem de ficar ""
|
||||
volumeName: mf-documents-storage-limbosolutions-com
|
||||
accessModes:
|
||||
- ReadWriteMany
|
||||
resources:
|
||||
requests:
|
||||
storage: 64Gi
|
||||
|
||||
|
||||
---
|
||||
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: media-music-storage-limbosolutions-com
|
||||
namespace: cloud-limbosolutions-com
|
||||
spec:
|
||||
storageClassName: "" # isto tem mesmo de ficar senão não funciona não sei pq.. tem de ficar ""
|
||||
volumeName: media-music-storage-limbosolutions-com
|
||||
accessModes:
|
||||
- ReadWriteMany
|
||||
resources:
|
||||
requests:
|
||||
storage: 64Gi
|
||||
|
||||
---
|
||||
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: media-videos-storage-limbosolutions-com
|
||||
namespace: cloud-limbosolutions-com
|
||||
spec:
|
||||
storageClassName: "" # isto tem mesmo de ficar senão não funciona não sei pq.. tem de ficar ""
|
||||
volumeName: media-videos-storage-limbosolutions-com
|
||||
accessModes:
|
||||
- ReadWriteMany
|
||||
resources:
|
||||
requests:
|
||||
storage: 2000Gi
|
||||
|
||||
---
|
||||
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: media-gaming-storage-limbosolutions-com
|
||||
namespace: cloud-limbosolutions-com
|
||||
spec:
|
||||
storageClassName: "" # isto tem mesmo de ficar senão não funciona não sei pq.. tem de ficar ""
|
||||
volumeName: media-gaming-storage-limbosolutions-com
|
||||
accessModes:
|
||||
- ReadWriteMany
|
||||
resources:
|
||||
requests:
|
||||
storage: 64Gi
|
||||
|
||||
---
|
||||
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: itstorage-storage-limbosolutions-com
|
||||
namespace: cloud-limbosolutions-com
|
||||
spec:
|
||||
storageClassName: "" # isto tem mesmo de ficar senão não funciona não sei pq.. tem de ficar ""
|
||||
volumeName: itstorage-storage-limbosolutions-com
|
||||
accessModes:
|
||||
- ReadWriteMany
|
||||
resources:
|
||||
requests:
|
||||
storage: 1000Gi
|
||||
---
|
||||
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: mf-photos-storage-limbosolutions-com
|
||||
namespace: cloud-limbosolutions-com
|
||||
spec:
|
||||
storageClassName: "" # isto tem mesmo de ficar senão não funciona não sei pq.. tem de ficar ""
|
||||
volumeName: mf-photos-storage-limbosolutions-com
|
||||
accessModes:
|
||||
- ReadWriteMany
|
||||
resources:
|
||||
requests:
|
||||
storage: 64Gi
|
||||
---
|
||||
|
||||
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: mf-nexcloud-storage-limbosolutions-com
|
||||
namespace: cloud-limbosolutions-com
|
||||
spec:
|
||||
storageClassName: "" # isto tem mesmo de ficar senão não funciona não sei pq.. tem de ficar ""
|
||||
volumeName: mf-nexcloud-storage-limbosolutions-com
|
||||
accessModes:
|
||||
- ReadWriteMany
|
||||
resources:
|
||||
requests:
|
||||
storage: 64Gi
|
||||
---
|
||||
13
deploy/app/cronjobs/secret.yaml
Normal file
13
deploy/app/cronjobs/secret.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: backup-secret
|
||||
namespace: cloud-limbosolutions-com
|
||||
data:
|
||||
PBS_REPOSITORY: ${PBS_REPOSITORY}
|
||||
PBS_PASSWORD: ${PBS_PASSWORD}
|
||||
PBS_FINGERPRINT: ${PBS_FINGERPRINT}
|
||||
DB_NAME: ${DB_NAME}
|
||||
DB_HOST: ${DB_HOST}
|
||||
# get sql client user and password from nextcloud secret
|
||||
17
deploy/app/kustomization.yaml
Normal file
17
deploy/app/kustomization.yaml
Normal file
@@ -0,0 +1,17 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
resources:
|
||||
- cronjobs/backups/backup-borg-offsite-cronjob.yaml
|
||||
- cronjobs/backups/backup-pbs-cronjob.yaml
|
||||
|
||||
secretGenerator:
|
||||
- name: gitea-backup
|
||||
namespace: git-limbosolutions-com
|
||||
envs:
|
||||
- cronjobs/backups/.env.d/secrets
|
||||
files:
|
||||
- BORG_KEY=cronjobs/backups/.env.d/borg_key
|
||||
- SSH_ID_RSA=cronjobs/backups/.env.d/id_rsa
|
||||
|
||||
generatorOptions:
|
||||
disableNameSuffixHash: true
|
||||
Reference in New Issue
Block a user