# Install and Configure Velero

# Introduction

Velero is an open-source tool to safely back up, recover, and migrate Kubernetes clusters and persistent volumes. It works both on premises and in a public cloud. Velero consists of a server process running as a deployment in your Kubernetes cluster and a command-line interface (CLI). Velero uses the Kubernetes API to capture the state of cluster resources and to restore them when necessary. Backups can capture subsets of the cluster’s resources, filtering by namespace, resource type, and/or label selector, providing a high degree of flexibility around what’s backed up and restored.

# Installation Process

Installing the Velero Client on K8’s master node:

  1. Download the velero tar.gz release from (https://github.com/vmware-tanzu/velero/releases (opens new window)) on K8’s master node
master: > wget https://<<link_copy_from_release_page>>
  1. Once the download complete, extract the tarball using tar
master: > tar -xvzf velero-v1.10.2-rc.1-linux-amd64.tar.gz
  1. The K8’s master should now contain the extracted velero-v1.10.2-rc.1-linux-amd64.tar.gz move the velero executable out of the temporary directory and add it to your PATH
master: > mv velero-v1.10.2-rc.1-linux-amd64/velero /usr/local/bin/velero

Get AWS access key ID and secret access key:

  1. Open the IAM console at https://console.aws.amazon.com/iam/ (opens new window)

  2. On the navigation menu, choose Users.

  3. Choose your IAM username (not the check box).

  4. Open the Security credentials tab, and then choose Create access key.

  5. To see the new access key, choose Show. Your credentials resemble the following:

    • Access key ID: xxxxxxxxxxxxxx
    • Secret access key: xxxxxxxxxxxxxx
  6. To download the key pair, choose Download .csv file. Store the .csv file with keys in a secure location.

Create AWS S3 bucket to take backup & restore:

  1. Sign into the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/ (opens new window)

  2. Choose Create bucket.

    The Create bucket wizard opens.

  3. In Region, choose the AWS Region where you want the bucket to reside.

  4. Choose Create bucket.

  5. After creating bucket, the image looks like below.

  1. Now user have the access_key_id & secret key from aws. create the cloud-credentials file in below format.
master: > vi cloud-credentials
[default]
aws_access_key_id=xxxxxxxxxxxxxxxx
aws_secret_access_key=xxxxxxxxxxxxxxxxxx

Installing the Velero Server once you are ready with the appropriate bucket and backup location settings, it is time to install Velero. Run the following command, substituting your values where required:

Example:

master: > velero install --provider aws --plugins velero/velero-plugin-for-aws:v1.5.0 --bucket velerobucket10 --secret-file ./cloud-credentials --backup-location-config region=ap-south-1 --snapshot-location-config region=ap-south-1

You should see the following output:

CustomResourceDefinition/backups.velero.io: attempting to create resource
CustomResourceDefinition/backups.velero.io: attempting to create resource client
CustomResourceDefinition/backups.velero.io: created
CustomResourceDefinition/backupstoragelocations.velero.io: attempting to create resource
CustomResourceDefinition/backupstoragelocations.velero.io: attempting to create resource client
CustomResourceDefinition/backupstoragelocations.velero.io: created
CustomResourceDefinition/deletebackuprequests.velero.io: attempting to create resource
CustomResourceDefinition/deletebackuprequests.velero.io: attempting to create resource client
CustomResourceDefinition/deletebackuprequests.velero.io: created
CustomResourceDefinition/downloadrequests.velero.io: attempting to create resource
CustomResourceDefinition/downloadrequests.velero.io: attempting to create resource client
CustomResourceDefinition/downloadrequests.velero.io: created
CustomResourceDefinition/podvolumebackups.velero.io: attempting to create resource
CustomResourceDefinition/podvolumebackups.velero.io: attempting to create resource client
CustomResourceDefinition/podvolumebackups.velero.io: created
CustomResourceDefinition/podvolumerestores.velero.io: attempting to create resource
CustomResourceDefinition/podvolumerestores.velero.io: attempting to create resource client
CustomResourceDefinition/podvolumerestores.velero.io: created
CustomResourceDefinition/resticrepositories.velero.io: attempting to create resource
CustomResourceDefinition/resticrepositories.velero.io: attempting to create resource client
CustomResourceDefinition/resticrepositories.velero.io: created
CustomResourceDefinition/restores.velero.io: attempting to create resource
CustomResourceDefinition/restores.velero.io: attempting to create resource client
CustomResourceDefinition/restores.velero.io: created
CustomResourceDefinition/schedules.velero.io: attempting to create resource
CustomResourceDefinition/schedules.velero.io: attempting to create resource client
CustomResourceDefinition/schedules.velero.io: created
CustomResourceDefinition/serverstatusrequests.velero.io: attempting to create resource
CustomResourceDefinition/serverstatusrequests.velero.io: attempting to create resource client
CustomResourceDefinition/serverstatusrequests.velero.io: created
CustomResourceDefinition/volumesnapshotlocations.velero.io: attempting to create resource
CustomResourceDefinition/volumesnapshotlocations.velero.io: attempting to create resource client
CustomResourceDefinition/volumesnapshotlocations.velero.io: created
Waiting for resources to be ready in cluster...
Namespace/velero: attempting to create resource
Namespace/velero: attempting to create resource client
Namespace/velero: created
ClusterRoleBinding/velero: attempting to create resource
ClusterRoleBinding/velero: attempting to create resource client
ClusterRoleBinding/velero: created
ServiceAccount/velero: attempting to create resource
ServiceAccount/velero: attempting to create resource client
ServiceAccount/velero: created
Secret/cloud-credentials: attempting to create resource
Secret/cloud-credentials: attempting to create resource client
Secret/cloud-credentials: created
BackupStorageLocation/default: attempting to create resource
BackupStorageLocation/default: attempting to create resource client
BackupStorageLocation/default: created
VolumeSnapshotLocation/default: attempting to create resource
VolumeSnapshotLocation/default: attempting to create resource client
VolumeSnapshotLocation/default: created
Deployment/velero: attempting to create resource
Deployment/velero: attempting to create resource client
Deployment/velero: created
Velero is installed! ⛵ Use 'kubectl logs deployment/velero -n velero' to view the status.

Once the deployment is ready you can be able to see the status using below cmd

master: > oc get po -n velero
NAME READY STATUS RESTARTS AGE
velero-798b86bf47-2s68n 1/1 Running 0 36s

# Backup and restore

Follow below steps to backup and restore:

To install wordpress application follow the below link

Example: Deploying WordPress and MySQL with Persistent Volumes | Kubernetes (opens new window)

  1. Below figure shows wordpress app resources under project wordpress

  2. Run the following command to take backup

  3. Run below command to get available backups in Velero

Also, user can check from AWS S3 bucket

  1. Now user can Delete the wordpress application and can restore from AWS S3bucket . Run the below command to restore the backup in Velero.

  2. Run the below command to list the restore.

Verification: Verify wordpress resources restored or not.