2024-12-25Hünkar Döner
EKS Backup Strategies: Backup and Restore with Velero
BackupVeleroEKSDisaster Recovery
E
EKS Backup Strategies: Backup and Restore with Velero
The perception that "Kubernetes is for stateless applications, no need for backup" is wrong. StatefulSets, databases, and critical configurations (YAML) running on Amazon EKS must be backed up. What will you do if someone accidentally runs the kubectl delete namespace production command?
Answer: Velero. Developed by VMware, Velero is the standard tool of the Kubernetes backup world.
What Does Velero Do?
- Cluster Resources: Backs up all YAML files (Deployment, Service, ConfigMap).
- Persistent Volumes: Backs up data on disk by taking EBS snapshots.
Velero Installation on EKS
1. S3 Bucket and IAM Preparation
Create an Amazon S3 bucket where backups will be stored. Create an IAM user or IRSA (IAM Role) so Velero can write to this bucket.
2. Velero CLI and Server Installation
Install Velero CLI on your computer and then install the server on the EKS cluster:
velero install --provider aws --plugins velero/velero-plugin-for-aws:v1.6.0 --bucket my-eks-backups --backup-location-config region=eu-central-1 --snapshot-location-config region=eu-central-1 --secret-file ./credentials-velero
Backing Up and Restoring
- Backup:
velero backup create my-backup --include-namespaces production - Scheduled Backup:
velero schedule create daily-backup --schedule="0 1 * * *"(Every night at 01:00). - Restore:
velero restore create --from-backup my-backup
Velero is also a lifesaver before EKS version upgrades. If a problem occurs, you can instantly return to the old version and data.