Home » Kubernetes Cluster Backup/Migration using Velero

Kubernetes Cluster Backup/Migration using Velero

by admin

Kubernetes Cluster Backup/Migration Using Velero

Kubernetes Cluster Backup/Migration Using Velero

Table of Contents

1       Overview: Velero 

2       Architecture: 

3       Usecases: 

4       How Velero works: 

Overview: Velero

Velero is an open source tool for safely backing up and restoring resources in a Kubernetes cluster, performing disaster recovery, and migrating resources and persistent volumes to another Kubernetes cluster.

Velero offers key data protection features, such as scheduled backups, retention schedules, and pre or post backup hooks for custom actions. Velero can help protect data stored in persistent volumes and makes your entire Kubernetes cluster more resilient.

Architecture:

Velero Backup Solution Architecture

Velero Backup Solution Architecture

Usecases:

  1. Back up your cluster and restore it in case of loss.
  2. Recover from disaster.
  3. Copy cluster resources to other clusters.
  4. Replicate your production environment to create development and testing environments.
  5. Take a snapshot of your application’s state before upgrading a cluster.

How Velero works:

Each Velero operation–on-demand backup, scheduled backup, restoration–is a custom resource that is defined with a Kubernetes custom resource definition, or CRD, and stored in etcd. Velero includes controllers that process the CRD’s to back up and restore resources. You can back up or restore all objects in your cluster, or you can filter objects by type, namespace, or label.

Data protection is a chief concern for application owners who want to make sure that they can restore a cluster to a known good state, recover from a crashed cluster, or migrate to a new environment. Velero provides those capabilities.

Procedure for Backup and Restore of Kubernetes cluster in AWS:

Step 1: Create an S3 bucket and set the following permissions

  1. Create a bucket with custom name.
  2. Go to Permissions section in S3 and attach the below given bucket policy.
{

"Id":"Policy1612005814976",

"Version":"2012-10-17",

"Statement":[

{

"Sid":"Stmt1612005810869",

"Action":[

"s3:AbortMultipartUpload",

"s3:DeleteObject",

"s3:GetObject",

"s3:ListBucketMultipartUploads",

"s3:PutObject"

],

"Effect":"Allow",

"Resource":[

"arn:aws:s3:::<BUCKET>",

"arn:aws:s3:::<BUCKET>/*"

],

"Principal":{

"AWS":[

"arn:aws:iam::<xxxxxxxxx>:user/<xxxx>"

]

}

}

]

}

Step 2: Download & Install Velero

mkdir velero

cd velero
wget https://github.com/vmware-tanzu/velero/releases/download/v1.5.3/velero-v1.5.3-linux-amd64.tar.gz
tar xzvf velero-v1.5.3-linux-amd64.tar.gz

cd velero-v1.5.3-linux-amd64

sudo cp -r velero-v1.5.3-linux-amd64/velero /usr/local/bin/

Step 3: Setup Velero credentials

Create a credentials file with name “credentials-velero”.  (You can give any name of your choice)

vi credentials-velero
[default]
aws_access_key_id = <aws_access_key_id>
aws_secret_access_key = <aws_secret_access_key>

Step 4: Install Velero

velero install \

--provider aws \

--plugins velero/velero-plugin-for-aws:v1.1.0 \

--bucket <BUCKET> \

--backup-location-config region=ca-central-1 \

--use-volume-snapshots=false \

--secret-file ./credentials-velero \

--use-restic

Step 5: Taking backup

We can backup entire cluster or backup a specific name space or objects like pod, deployment, etc using Velero backup command.Here for the demo we are going to back up a name space in k8’s cluster.

Step 1: To list all the name spaces created in the cluster type the following command.

kubectl get ns

The above command will list out all the name spaces so that you can choose the once you want to backup

Step 2: Create a backup for a name space in Kubernetes

velero backup create firstbackup  --include-namespace test-name-space

This will create a backup in the s3 bucket.

Step 3 : To get the list of backup files type the following command

velero backup get

Step 4: To get the detailed view of backup use the following command

velero backup describe firstbackup

Step 6: Restoring the Backup

Now that we have created our backup. We shall now delete the name space “test-name-space” and restore it from s3 using velero

Step 1: To delete the name space

kubectl delete ns test-name-space

Wait for the name space to be deleted

Step 2: Then restore the namespace from the backup we have just crated

velero restore create --from-backup firstbackup

Now let the restoration to be completed.

Step 3: After success restoration we can now check the name space which we deleted

kubectl get ns

This will list all namespaces in Kubernetes including our deleted one

By following the above-mentioned steps, we can create a smooth Backup and Restore of kubernetes cluster to AWS

 

Anusha Ravindra – DevOps Trainee

Sai Krishna Sirigiri – DevOps Engineer

 

Want to know? Contact us now for a free consultation

Cloud computing Insights and Resources

Cloud Computing Advantages and Disadvantages

Advantages and Disadvantages of Cloud Computing

Cloud technology and agility are the newest business trends. Is this technology new? Absolutely not. It has been in the ...
Read More
The Future of Cloud Computing: Top 10 Trends CIOs Should Know

The Future of Cloud Computing: Top 10 Trends CIOs Should Know

On the future of cloud computing trends, all IT experts agree that it will be at the forefront of all ...
Read More
Demand for Cloud Computing Professionals on Rise

The Growing Demand for Cloud Computing professionals [2021]

To build their digital presence and stay updated with changing market needs, during these pandemic times, every business is leveraging ...
Read More
Kubernetes Cluster Backup/Migration using Velero

Kubernetes Cluster Backup/Migration using Velero

Table of Contents 1       Overview: Velero  2       Architecture:  3       Usecases:  4       How Velero works:  Overview: Velero Velero is an open ...
Read More
How MSP staffing strategies have changed

How MSP staffing strategies have changed forever due to pandemic and what you can do to stay ahead

The current ongoing pandemic has dramatically changed the way organizations execute their business plans. This pandemic has forced organizations to ...
Read More
AWS Systems Manager

AWS Systems Manager – An Overview

Ever thought of automating repetitive administrative tasks of managing EC2 machines on AWS? Then it is time to start exploring ...
Read More
Easy Live Video using AIML

Easy Live Video using AI/ML on Top of Elemental MediaLive

With the increased usage of video streaming for work purposes, there is a strong need of monitoring of live and ...
Read More
We often miss out basics of AWS RDS

We often miss out basics of AWS RDS (Relational Database Services)

We all know that what variety and amount of data we are generating today, in this data-driven world, our digital life increasingly ...
Read More
Covid-19 : Impact On Cloud Computing Adoption

Covid-19 : Impact on Cloud Computing Adoption

The year 2020 will be touted as the golden year for cloud computing. Covid-19 has made tech infrastructure companies find ...
Read More