备份恢复

Velero 是一个提供 Kubernetes 集群和持久卷的备份、迁移以及灾难恢复等的开源工具。

安装

https://github.com/heptio/velero/releases 下载最新的稳定版。

以 Azure 为例,安装 Velero 需要以下步骤:

(1) 创建存储账户

AZURE_BACKUP_RESOURCE_GROUP=Velero_Backups
az group create -n $AZURE_BACKUP_RESOURCE_GROUP --location WestUS

AZURE_STORAGE_ACCOUNT_ID="velero$(uuidgen | cut -d '-' -f5 | tr '[A-Z]' '[a-z]')"
az storage account create \
    --name $AZURE_STORAGE_ACCOUNT_ID \
    --resource-group $AZURE_BACKUP_RESOURCE_GROUP \
    --sku Standard_GRS \
    --encryption-services blob \
    --https-only true \
    --kind BlobStorage \
    --access-tier Hot

BLOB_CONTAINER=velero
az storage container create -n $BLOB_CONTAINER --public-access off --account-name $AZURE_STORAGE_ACCOUNT_ID

(2)创建 service principal

(3)启动 Velero

备份

创建定期备份:

灾难恢复

迁移

首先,在集群 1 中创建备份(默认 TTL 是 30 天,你可以使用 --ttl 来修改):

然后,为集群 2 配置 BackupStorageLocations 和 VolumeSnapshotLocations,指向与集群 1 相同的备份和快照路径,并确保 BackupStorageLocations 是只读的(使用 --access-mode=ReadOnly)。接下来,稍微等一会(默认的同步时间为 1 分钟),等待 Backup 对象创建成功。

最后,执行数据恢复:

参考文档

最后更新于