kubectl get all --all-namespaces -o yaml > all-deploy-services.yaml
与其备份单个资源,不如备份ETCD:
etcd.service
--data-dir=/var/lib/etcd
etcd也自带快照功能
ETCDCTL_API=3 etcdctl \
snapshot save snapshot.db
snapshot status snapshot.db ##查看备份状态
Restore:会初始化新的集群配置,将etcd配置为新成员,以防止新成员加入现有集群
service kube-apiserver stop
snapshot restore snapshot.db --data-dir /var/lib/etcd-from-backup ##使用新的数据目录
systemctl daemon-reload
service etcd restart
service kube-apiserver start
可以对备份指定访问端口和密钥信息:
snapshot save snapshot.db
--endpoints=https://127.0.0.1:2379
--cacert=/etc/etcd/ca.crt
--cert=/etc/etcd/etcd-server.crt
--key=/etc/etcd/etcd-server.key
标签:service,Kubernetes,--,db,备份,二十一,snapshot,etcd
From: https://www.cnblogs.com/Bota5ky/p/16622398.html