You can check MinIO deployment – https://kdinesh.in/minio/
Velero: –
Velero is an open-source tool to safely backup and restore, perform disaster recovery, and migrate Kubernetes cluster resources and persistent volumes.
Kubernetes Cluster : –
You can check below my old posts links to deploy Kubernetes Clusters –
vSphere Tanzu Deployment using Ha proxy – https://kdinesh.in/vmwaretkgs/
vSphere Tanzu Deployment using AVI Load Balancer – https://kdinesh.in/vratkgs/
Redhat OpenShift Deployment – https://kdinesh.in/ocp/
Opensource Kubernetes – https://kdinesh.in/kubernetes/
MinIO Configuration
Create a bucket in MinIO.
Create an Access key. Copy the secret key.
Velero Installation
I am using Tanzu Kubernetes Cluster. I am accessing the TKG Cluster using the Linux Jump box.
Download the Velero tar file.
$ wget https://github.com/vmware-tanzu/velero/releases/download/v1.12.0/velero-v1.12.0-linux-amd64.tar.gz
Extract tar file
$ tar zxf velero-v1.12.0-linux-amd64.tar.gz
Move the Velero file to /usr/local/bin.
$ mv velero-v1.12.0-linux-amd64/velero /usr/local/bin/
Check Velero version
Velero deployment on Kubernetes cluster, testing backup and restoration: –
You can download the following file using the below link
Link – https://github.com/Dineshk1205/postgredbbackup
Create a postgres directory. Copy postgres and minio.credentials file.
(Note: – Update minio.credentials file with the above-created minio access key and secret minio aws_access_key_id(mini access key) and aws_secret_access_key(minio secret))
For testing purposes, deploy the PostgreSQL database with PVC (vSphere CSI used)
Create a namespace postgres
$ kubectl create ns postgres
kubectl create secret generic “secret name” –from-literal=POSTGRE_USER=” username” –from-literal=POSTGRES_PASSWORD=” password” -n namespacename
$ kubectl create secret generic postgres –from-literal=POSTGRE_USER=” backuptest” –from-literal=POSTGRES_PASSWORD=” Backup@123” -n postgres
Next, deploy Postgres DB.
Switch to postgres dir
$ kubectl apply -f .
The postgres pod is running. You can check the PVC volume in vSphere.
Before taking a backup. Login to postgres pod and create a database.
Login to the postgres pod
$ kubectl exec -it postgres-869b5dbd8-6snvg -n postgres — psql -h localhost -U backuptest –password -p 5432 posgredb
(Note: – In the above command, replace the pod name, dbuser and password with your pod, dbuser and password)
Create a new DB.
CREATE DATABASE database name;
$ CREATE DATABASE velerotest;
Exit database
$ \q
Deploy Velero in Kubernetes cluster: –
velero install –provider aws –plugins velero/velero-plugin-for-aws:main –bucket “”bucket name” –secret-file “minio-credentailes_file” –use-volume-snapshots=true –uploader-type Restic/Kopia –snapshot-location-config region=minio –use-node-agent –backup-location-config region=minio,s3ForcePathStyle=”true”,s3Url=”MinioURL”
Upload type chosen based on your requirements – Restic/kolpia
You can check a comparison between Restic/kolpia – https://velero.io/docs/v1.12/performance-guidance/
I am using Restic.
$ velero install –provider aws –plugins velero/velero-plugin-for-aws:main –bucket k8s –secret-file ./minio.credentials –use-volume-snapshots=true –uploader-type restic –snapshot-location-config region=minio –use-node-agent –backup-location-config region=minio,s3ForcePathStyle=”true”,s3Url=http://172.16.0.6:9000
Check Velero pod status.
For taking a pod with PVC, backup annotation is required. Add annotation to the postgres pod.
kubectl -n “namespace” annotate pod/” podname” backup.velero.io/backup-volumes=volumename1, volumename2…
$ kubectl -n postgres annotate pod/postgres-869b5dbd8-6snvg backup.velero.io/backup-volumes=postgredb
Taking a Postgres DB Backup
velero backup create “backupname” –include-namespaces “namespace”
$ velero backup create postgres-backup –include-namespaces postgres
You can check the backup status.
velero backup describe “backup name”
$ velero backup describe postgres-backup
The backup was completed successfully.
Check in the MinIO Dashboard. In Bucket, backup files are created.
For testing the backup. Delete postgres deployment.
Switch to postgres
$ kubectl delete -f .
Postgres and PVC terminated.
Check vSphere – postgres PVC deleted.
Restoring postgres DB Backup: –
velero restore create –from-backup “backup name”
$ velero restore create –from-backup postgres-backup
You can also schedule backup using the following command – velero schedule create “backup name” –schedule=”@daily” –selector app=” label”
Check restore status
The restoration was completed successfully.
Postgres pods were restored successfully.
Check vSphere – PVC restored successfully.
Verify Postgres db data. Data also restored (velerotest db is present in DB)
Shipping a new version of an application is always a small act of faith. Even…
The following steps demonstrate how to back up and restore an OpenShift virtual machine using…
OpenShift Virtualization allows virtual machines (VMs) to run natively on Kubernetes alongside container workloads. Using…
Red Hat OpenStack Services on OpenShift (RHOSO) provides the foundation to build a private or public…
Kubernetes (often shortened to “K8s”) is an open-source system for automating the deployment, scaling, and…
Ceph is an open-source, distributed storage platform that provides object, block, and file storage in…
View Comments