Cloud Intermediate
Kubernetes Backup and Disaster Recovery¶
KubernetesBackupDisaster RecoveryVelero 5 min read
Backup and recovery strategies for Kubernetes clusters. Velero, etcd backup, PV snapshots and DR plans.
What to Back Up¶
- etcd — cluster state (most critical)
- Kubernetes manifests — Deployments, Services, ConfigMaps, Secrets
- Persistent Volumes — application data
- Custom Resources — CRDs and their instances
Velero¶
# Installation
velero install \
--provider aws \
--bucket velero-backups \
--secret-file ./credentials \
--plugins velero/velero-plugin-for-aws:v1.9.0
# Backup
velero backup create full-backup --include-namespaces '*'
# Scheduled backup
velero schedule create daily-backup \
--schedule="0 2 * * *" \
--ttl 720h
etcd Backup¶
ETCDCTL_API=3 etcdctl snapshot save /backup/etcd-snapshot.db \
--endpoints=https://127.0.0.1:2379 \
--cacert=/etc/kubernetes/pki/etcd/ca.crt \
--cert=/etc/kubernetes/pki/etcd/server.crt \
--key=/etc/kubernetes/pki/etcd/server.key
# Restore
ETCDCTL_API=3 etcdctl snapshot restore /backup/etcd-snapshot.db \
--data-dir=/var/lib/etcd-new
Summary¶
Backup and DR strategies are critical for production Kubernetes. Velero for manifests and PVs, etcd snapshots for cluster state. Test your restores regularly!
Need Help with Implementation?¶
Our team has experience designing and implementing modern architectures. We’re happy to help.