【kubernetes】基于velero的DR方案

容灾恢复是绝大多数企业级应用的基本要求,对于kubernetes的容灾,其中几个关键的因素是需要考虑的。

  • 备份对象粒度
  • 能够备份集群resource以及持续存储中的数据
  • 针对Kubernetes namespace级别的备份恢复
  • 原生和共有云的支持

使用velero可以对kubernetes集群进行备份和恢复,降低集群DR造成的影响。velero的基本原理就是将集群的source,以及persistent volumes中的数据备份到对象存储中,在恢复的时候将数据从对象存储中拉取下来。

Velero (formerly Heptio Ark) gives you tools to back up and restore your Kubernetes cluster resources and persistent volumes. You can run Velero with a cloud provider or on-premises. Velero lets you:

  • Take backups of your cluster and restore in case of loss.
  • Migrate cluster resources to other clusters.
  • Replicate your production cluster to development and testing clusters.

backup workflowVelero支持原生的,以及公有云环境的备份和恢复,支持的provider如下:
在这里插入图片描述在这里插入图片描述下面以azure为实例说明,如何使用velero对kubernetes进行备份和恢复。

前置条件

  • An Azure Subscription
  • resource group
  • Storageaccount
  • sp

其中集群备份的数据放在azure storageaccount Blob中,PV的snapshot放到指定的resourcegroup中,其中注意的是PV绑定的disk是不可以跨区打快照,比如东二的managed disk的snapshot只能放在东二,不能放到北二。

安装velero

# download velero cli
Wget https://github.com/vmware-tanzu/velero/releases/download/v1.3.0/velero-v1.3.0-linux-amd64.tar.gz
# config credentials
cat << EOF  > ./credentials-velero
AZURE_SUBSCRIPTION_ID=
AZURE_TENANT_ID=
AZURE_CLIENT_ID=
AZURE_CLIENT_SECRET=
AZURE_RESOURCE_GROUP=
AZURE_CLOUD_NAME=AzureChinaCloud
EOF
#install
velero install \
    --provider azure \
    --plugins velero/velero-plugin-for-microsoft-azure:v1.0.1 \
    --bucket velero \
    --secret-file ./credentials-velero \
    --backup-location-config resourceGroup=,storageAccount=,subscriptionId= \
    --snapshot-location-config apiTimeout=5m,resourceGroup=,subscriptionId=

backup
支持两个方式的备份,按需手动备份方式,就是手动触发一次备份,备份的时候可以全集群备份,或者选择指定的资源备份,选择的颗粒度包括指定的namespace,指定label的resource。还支持定时备份,指定备份时间间隔进行自动的备份。

#On-demand backups
velero backup create backup-On-demand backups --exclude-namespaces kube-node-lease,kube-public,kube-system,velero

#Scheduled backups
velero create schedule backup-every-24h --schedule="@every 24h" --snapshot-volumes=true --ttl 720h0m0s

restore
恢复的时候也是可以选择整个集群,或者指定的资源进行恢复。

#restore all
velero restore create restore-every-24h --from-backup backup-every-24h-20200831082549 --wait
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值