Velero 实践

215 阅读1分钟

本文主要讲 velero 进行kubernetes集群备份与迁移操作的

下载 Velero 客户端

Velero 由客户端和服务端组成,服务器部署在目标 k8s 集群上,而客户端则是运行在本地的命令行工具。

  • 前往 Velero 的 Release 页面 下载客户端,直接在 GitHub 上下载即可
  • 解压 release 包
  • 将 release 包中的二进制文件 velero 移动到 $PATH 中的某个目录下
  • 执行 velero -h 测试

本文主要使用的 minio S3对象存储

备份测试

  • 解释各命令的含义

    include-resource:服务类型(Deployment) include-namespaces 命名空间

velero-plugin 项目中已经给出 example 用于测试备份。

  • 部署测试服务
kubectl apply -f examples/base.yaml
  • 对 nginx-example 所在的 namespace 进行备份
velero backup create nginx-backup --include-namespaces nginx-example --wait
  • 模拟 namespace 被误删
kubectl delete namespaces nginx-example
  • 使用 Velero 进行恢复
velero restore create --from-backup nginx-backup --wait
  • 使用Velero进行多命名空间恢复
velero restore create <restore-name> --include-namespaces <namespace1>,<namespace2> --from-backup <backup-name>
  • 备份所有命名空间deployment
velero backup create <backup-name> --include-resources deployments
  • 备份整个集群,包括集群范围的资源
velero backup create <backup-name>