In this section, we will take a look at backup and restore methods
Imperative way
A good practice is to store resource configurations on source code repositories like github.
$ kubectl get all --all-namespaces -o yaml > all-deploy-services.yaml (only for few resource groups)
There are many other resource groups that must be considered. There are tools like ARK
or now called Velero
by Heptio that can do this for you.
So, instead of backing up resources as before, you may choose to backup the ETCD cluster itself.
You can take a snapshot of the etcd database by using etcdctl
utility snapshot save command.
$ ETCDCTL_API=3 etcdctl snapshot save snapshot.db
$ ETCDCTL_API=3 etcdctl snapshot status snapshot.db
$ service kube-apiserver stop
$ systemctl daemon-reload
$ service etcd restart
$ service kube-apiserver start
$ ETCDCTL_API=3 etcdctl \
snapshot save /tmp/snapshot.db \
--endpoints=https://[127.0.0.1]:2379 \
--cacert=/etc/kubernetes/pki/etcd/ca.crt \
--cert=/etc/kubernetes/pki/etcd/etcd-server.crt \
--key=/etc/kubernetes/pki/etcd/etcd-server.key