velero 是一个#kubernetes 的备份工具 安装
-
准备 binary
-
通过 binary 在集群内安装 plugins、provider 是必选项
bash velero install \ --use-node-agent \ --plugins velero/velero-plugin-for-aws:v1.2.1 \ --use-volume-snapshots=false \ --bucket velero \ --secret-file ./cred.toml \ --backup-location-config region=minio,s3ForcePathStyle="true",s3Url=https://172.10.0.2:32348 \ --provider aws
核心概念 -
FSB Filesystem Backup ,不依赖 provider 的 snapshot 基础设施,在文件层面实施备份。文档 实现上是在 restic 这种同步工具上套了一层壳,使其适配 k8s 环境 一些用法
-
Tips
- 用来换 storage-class 这种场景下,基本都是用 velero 的 FSB
- 好像没有办法只备份 pv/pvc。需要连同 pod 一起备份才能正确恢复。因为 velero 需要 pods 挂着磁盘才能用#restic 去读 提了一个#issue Restic backups of persistentvolume are skipped during restore #6266
- 条件允许的情况下被备份的 pv 的 pod 应该关掉,然后创建一个 dummy pod 挂盘以避免备份时产生的数据不一致。
-
实操 0. 准备好
RestoreItemAction
配置文件,Changing PV/PVC Storage Classes- 对要备份的 pod 打个标记
kubectl -n apm annotate pod/main-prometheus-server-54f4d79fd5-sjxjv backup.velero.io/backup-volumes=storage-volume
- 创建备份
velero backup create prometheus-backup11 \ --selector app=prometheus \ --include-namespaces apm \ --wait
- 在另外一个命名空间恢复备份
velero restore create restore-10 --from-backup prometheus-backup11 \ --namespace-mappings apm:apm-restored10 \ --include-cluster-resources \ --wait