[Kubernetes (K8S)] Helm install Velero to backup, restore and migrate within Kubernetes (K8S)
Velero
Velero is an open source tool to safely backup and restore, perform disaster recovery, and migrate Kubernetes cluster resources and persistent volumes.
This article is about how to use Helm to install Velero on Kubernetes (K8S).
Velero (formerly Heptio Ark) gives you tools to back up and restore your Kubernetes cluster resources and persistent volumes. You can run Velero with a public cloud platform or on-premises. Velero lets you:
-
Take backups of your cluster and restore in case of loss.
-
Migrate cluster resources to other clusters.
-
Replicate your production cluster to development and testing clusters.
Velero consists of:
-
A server that runs on your cluster
-
A command-line client that runs locally
Prerequisites
-
Kubernetes (K8s) is an open-source system for automating deployment, scaling, and management of containerized applications.
For more information about installing and using Kubernetes (K8s), see the Kubernetes (K8s) Docs.
-
Helm is the best way to find, share, and use software built for Kubernetes.
1
2Mac OS X
brew install helmFor more information about installing and using Helm, see the Helm Docs.
-
Amazon Simple Storage Service (Amazon S3) is an object storage service offering industry-leading scalability, data availability, security, and performance.
See - https://aws.amazon.com/s3/ to learn more.
Usages
values.yaml
Edit values.yaml and replace content within {{ }}
or < >
.
1 | # values.yaml |
Install Release
Helm install Velero into Velero namespace.
1 | crate namespace: |
See pods about velero.
1 | kubectl get pods -n velero |
Examples
Install Velero CLI
Option 1: MacOS - Homebrew
1 | On macOS, you can use Homebrew to install the velero client: |
Option 2: GitHub release
-
- Download the latest release’s tarball for your client platform.
-
- Extract the tarball:
1 | tar -xvf <RELEASE-TARBALL-NAME>.tar.gz |
-
- Move the extracted velero binary to somewhere in your
$PATH
(/usr/local/bin
for most users).
- Move the extracted velero binary to somewhere in your
See Install the CLI Velero Docs - Basic Install - https://velero.io/docs/v1.7/basic-install/#install-the-cli to learn more.
Deploy examples/nginx-app/with-pv
First, deploy nginx-app
into namespace nginx-example
1 | kubectl apply -f examples/nginx-app/with-pv.yaml |
Run backup
Option 1 Create backup via yaml
Here is a sample Backup object with each of the fields documented manifests/Backup-nginx-example.yaml
.
1 | # manifests/Backup-nginx-example.yaml |
See - https://velero.io/docs/v1.7/api-types/backup/ to learn more.
Apply manifests/Backup-nginx-example.yaml
manifest file.
1 | kubectl apply -f manifests/Backup-nginx-example.yaml |
Option 2 Create backup via Velero CLI
1 | velero backup create nginx-backup --include-namespaces nginx-example |
Check Velero backup status
1 | velero backup get nginx-example |
Restore
Simulate a disaster:
1 | kubectl delete namespaces nginx-example |
Before continuing to the next step, check your cloud provider to confirm that the disk no longer exists.
Restore your lost resources:
1 | velero restore create --from-backup nginx-backup |
All resources of nginx-backup will restore.
FAQs
unable to locate ObjectStore plugin named velero.io/aws
Enable velero-plugin-for-aws
for initContainers.
1 | # values.yaml |
pod volume backup failed: error getting volume path on host
1 | time="2021-12-14T10:14:15Z" level=error msg="Error backing up item" backup=velero/argo-cd error="pod volume backup failed: error getting volume path on host: expected one matching path, got 0" error.file="/go/src/github.com/vmware-tanzu/velero/pkg/restic/backupper.go:184" error.function="github.com/vmware-tanzu/velero/pkg/restic.(*backupper).BackupPodVolumes" logSource="pkg/backup/backup.go:435" name=argo-cd-argocd-server-c8f945b59-j7b4c |
Velero’s restic daemonset uses a hostPath mount of /var/lib/kubelet/pods to get access to pods’ volume mounts. If a pod is using a hostPath mount, it won’t be mounted under that directory, so Velero isn’t able to access it.
See [FAQ] Why does Velero/restic not support hostPath volumes? · Discussion #3378 · vmware-tanzu/velero - https://github.com/vmware-tanzu/velero/discussions/3378 to learn more.
References
[2] Velero - https://velero.io/
[4] Kubernetes Getting Started | Pulumi - https://www.pulumi.com/docs/get-started/kubernetes/