Backing Up Your Amazon EKS Cluster with Velero
Kubernetes has become the backbone of modern cloud-native infrastructure, but managing mission-critical workloads requires robust disaster recovery strategies. When running applications on Amazon Elastic Kubernetes Service (EKS), ensuring that your cluster’s resources—deployments, services, persistent volumes, and configurations—are reliably backed up is essential. A single misconfiguration, accidental deletion, or infrastructure failure could disrupt your entire environment.
Velero (formerly Heptio Ark) is an open-source tool designed to simplify backup, restore, and migration of Kubernetes resources. It integrates seamlessly with cloud providers like AWS, allowing you to:
In this tutorial, you’ll learn how to set up Velero on an Amazon EKS cluster and configure backups to protect your applications and data. Let’s get started!
Prerequisites
Before you begin, ensure you have the following prerequisites:
Create an S3 Bucket
Create a single S3 bucket for backups (replace my-eks-backups-bucket with a globally unique name):
1 | REGION="us-west-2" |
Create an IAM Policy for Velero
Create a policy file velero-policy.json
with the following content:
1 | { |
Replace $BUCKET_NAME
with your bucket name (e.g., my-eks-backups-bucket).
Attach the Policy to an IAM User
Deploy Velero with Helm
Store AWS Credentials in Kubernetes Secrets
Create a Kubernetes secret to store your AWS credentials:
1 | kubectl create secret generic aws-credentials \ |
Create Custom Values File
Create a values.yaml
file with the following content:
1 | configuration: |
Replace my-eks-backups-bucket
with your S3 bucket name and us-west-2
with your AWS region.
Install Velero
1 | helm repo add vmware-tanzu https://vmware-tanzu.github.io/helm-charts |
Verify Installation
1 | kubectl get pods -n velero |
Perform a Backup
Create a backup of your EKS cluster:
1 | velero backup create eks-backup-$(date +%F) |
Check Backup Status
1 | velero backup describe eks-backup-2025-02-02 |
Schedule Automated Backups
Create a daily backup schedule (excludes kube-system
namespace):
1 |
|
List schedules:
1 | velero schedule list |
Restore from Backup
Restore the Entire Backup
1 | velero restore create --from-backup eks-backup-2025-02-02 |
Verify Restoration
1 | kubectl get all --all-namespaces |
Cleanup
Delete Backups
1 | velero backup delete eks-backup-2023-02-02 |
Uninstall Velero
1 | helm uninstall velero -n velero |
Delete the S3 Bucket
1 | aws s3 rb s3://my-eks-backups-bucket --force |
Best Practices
Follow these best practices to ensure your backups are reliable and secure:
Enable Bucket Encryption:
Use SSE-S3 or SSE-KMS to encrypt your S3 bucket.
1 | aws s3api put-bucket-encryption \ |
Use Restic for Persistent Volumes:
Add --default-volumes-to-restic
to Velero commands to back up PVs.
Monitor Backups:
Check Velero logs:
1 | kubectl logs -n velero deployment/velero -f |
Test Restores:
Regularly restore backups to a test cluster to ensure integrity.
Conclusion
In this tutorial, you learned how to set up Velero on an Amazon EKS cluster to back up and restore your Kubernetes resources. By following best practices and automating backups, you can protect your applications and data from accidental deletions, misconfigurations, and infrastructure failures. Velero simplifies disaster recovery and ensures your cluster is resilient to unforeseen events. For more information, refer to the Velero documentation.