Backup kubernetes cluster

Kubernetes version:1.21.0
Cloud being used: bare-metal
Installation method:kubeadm
Host OS: centos 7
CNI and version: Flannel v 0.3.1
CRI and version: Docker v 20.10.7

How to backup etcd in my current setup?

The etcdcl command gives and error:
-bash: etcdctl: command not found

The etcdctl command doesn’t work in my current setup please help.
Thanks

On CentOS, you have to get it yourself and it’s not packaged separately in the github repo.

[root@3cdac2ffafa9 ~]# curl -sLO https://github.com/etcd-io/etcd/releases/download/v3.5.0/etcd-v3.5.0-linux-amd64.tar.gz

[root@3cdac2ffafa9 ~]# tar -xzvf etcd-v3.5.0-linux-amd64.tar.gz 
etcd-v3.5.0-linux-amd64/
...truncated output ...
etcd-v3.5.0-linux-amd64/etcdutl
etcd-v3.5.0-linux-amd64/etcdctl
etcd-v3.5.0-linux-amd64/etcd

[root@3cdac2ffafa9 ~]# mv etcd-v3.5.0-linux-amd64/etcdctl /sbin/etcdctl

[root@3cdac2ffafa9 ~]# etcdctl version
etcdctl version: 3.5.0
API version: 3.5

After this, you need to set it up to talk to your cluster’s etcd. Which is not intuitive…

Looking at the steps I have for setting up Ubuntu with kubeadm, you need something like this in ~/.bashrc.

export ETCDCTL_API=3
export ETCDCTL_CACERT=/etc/kubernetes/pki/etcd/ca.crt
export ETCDCTL_CERT=/etc/kubernetes/pki/etcd/server.crt
export ETCDCTL_KEY=/etc/kubernetes/pki/etcd/server.key

I don’t know if the paths will be different on Cent OS or not, but after you get it working you can run:

$ etcdctl snapshot save <backup-file-location>
$ etcdctl snapshot restore  <backup-file-location>

More information on etcd related specifically to Kubernetes can be found here: