*Hello all, I saw a lot of ETCD backup process posts here but none of them are c . . .

OE:
@Andrey Tsediakov You don’t need them in simple single-node clusters. I think you do when you have multiple nodes in your control plane. In fact, you can get away with this if you have just a single control node but you have to run this on the control node:

ETCDCTL_API=3 etcdctl snapshot restore /tmp/etcd-backup.db --data-dir /var/lib/etcd-backup

Sarma Pasumarthi:
As I don’t have multi-node cluster on my Ubuntu VM, I followed course labs to prepare those instructions… Good to have but you can skip them if you are trying on single node clusters

OE:
It would have been preferable if the course had covered both scenarios (single node control plane vs multi-node control plane) and when to use the various switches

Rixin Lan:
Step 13: Should we change volumeMounts:
- mountPath: /var/lib/etcd
to the directory path to “/var/lib/etcd-from-backup” ?

Sarma Pasumarthi:
@Rixin Lan if you change volume that has “hostPath”, both volume mounts are using that volume so its a change at one place. Optionally, you can change volumeMounts and leave volume as it is…

Sarma Pasumarthi:
I will try again tomorrow and let you knoiw

Andrey Tsediakov:
@Sarma Pasumarthi when i perform restore on 2 node cluster with optional flags I am getting error :

Andrey Tsediakov:
controlplane $ ETCDCTL_API=3 etcdctl snapshot restore --endpoints=<https://127.0.0.1:2379> --cacert=/etc/kubernetes/pki/etcd/ca.crt --cert=/etc/kubernetes/pki/etcd/server.crt --key=/etc/kubernetes/pki/etcd/server.key --data-dir=/var/lib/etcd-from-backup --initial-advertise-peer-urls="<http://127.0.0.1:2380>" --initial-cluster="controlplane=<https://127.0.0.1:2380>" --initial-cluster-token="etcd-cluster-1" /opt/snapshot-pre-boot.db
Error: couldn't find local name "default" in the initial cluster configuration

OE:
@Andrey Tsediakov Use the name that etcd was using before your restore. You can find this by looking at the CLI switches that etcd uses in etcd.yaml. For example:

- --name=controlplane

vinod:
–name should be included as @OE mentioned otherwise we are getting error. after following all steps still getting this

controlplane $ ETCDCTL_API=3 etcdctl member list{"level":"warn","ts":"2020-11-30T06:24:17.530Z","caller":"clientv3/retry_interceptor.go:62","msg":"retrying of unary invoker failed","target":"<endpoint://client-7077dfca-0c84-4365-9540-01ad66dcffc3/127.0.0.1:2379>","attempt":0,"error":"rpc error: code = DeadlineExceeded desc = latest balancer error: all SubConns are in TransientFailure, latest connection error: connection closed"}
Error: context deadline exceeded

vinod:
Just few things which we need to take care while restoring:
1- --name < check your original etcd file under --command section> same should be included
2- --initial-cluster="<name as previous ones>=<https://127.0.0.1:2380>
3- need to change the files name as per below screenshot. undet hostpath and volumemounts section.
image.png

OE:
@vinod or you can just take the shortcut I mentioned if you are on the control plane node:

ETCDCTL_API=3 etcdctl snapshot restore /tmp/etcd-backup.db --data-dir /var/lib/etcd-backup

vinod:
got your point rather than giving all the parameters option while restoring we can use

ETCDCTL_API=3 etcdctl snapshot restore /tmp/etcd-backup.db --data-dir /var/lib/etcd-backup

and then changed the new data dir name in yaml file. still you need to change the name in all above mentioned location. correct me if am missing anything @OE

OE:
@vinod Using the above, you would only have to change a single line in your etcd.yaml file (the etcd-data volume mount path)

Lukáš Kubín:
I see no point in changing the --data-dir command parameter and volumeMount in the etcd manifest file. the only thing I’ve changed in there was the volumes.hostPath.etcd-data path, so that it reflects the directory the snapshot was restored to. it’s faster. or is there an issue I’m missing?

OE:
@Lukáš Kubín You are right. I’m not sure why he changed all of them in the lab solution. All you need is to change a single line as I mentioned above

Edmund Kueh:
Will be great if someone can explain how to know which option is mandatory for etcdctl snapshot save ….apart from just memorizing it…I do watch the solution video but no explanation on how to determine which option is mandatory…The same also applies to etcdctl snapshot restore…

Rixin Lan:
@Sarma Pasumarthi since ETCD works in a container : --data-dir=<path> use the path defined in volumeMounts ( not the real path in the system) and I used the same method as @vinod used when did the restore in the CKA lab

vinod:
just for conformation @OE @Lukáš Kubín

ETCDCTL_API=3 etcdctl snapshot restore /tmp/etcd-backup.db --data-dir /var/lib/etcd-backup

solutions worked i just changed the volume option.

Rixin Lan:
@Lukáš Kubín @OE , I make the changes ( change volumes.hostPath only) , it is working ( but do not know how to verify )