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

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 )

Edmund Kueh:
Is this correct ? I am trying to get the member list and there is remark “false” at the end of it…

Sarma Pasumarthi:
Here’s output from lab solution video…
image.png

Sarma Pasumarthi:
Guys, I tried my instructions again in CKA ETCD Backup/restore lab and they worked perfectly. I made minor changes to include volumeMounts but that’s about it.

OE:
@Sarma Pasumarthi Just a recommendation to have your code snippets

like this

to make reading your steps easier

Sarma Pasumarthi:
@OE Done. Thanks.

OE:
@Edmund Kueh Yes. False just means it is not a learner (refer to this for more - https://stackoverflow.com/questions/63433622/is-the-following-output-of-etcdctl-member-list-correct-and-etcd-cluster-is-in)

P S:
Good steps @Sarma Pasumarthi Couple of observations…

  1. when I’m executing in KataKoda practice environments. I often get below error while restoring :-
Error:  expected sha256 [192 34 116 2 72 172 108 91 102 14 204 205 193 70 163 254 156 27 205 148 190 171 99 63 234 149 201 220 37 154 105 68], got [178 153 122 181 91 182 33110 230 141 239 175 40 71 74 48 165 184 179 124 41 121 133 130 18 145 113 190 86 163 186 184]

I found an additional option that we can specify to ignore this sha integrity check - add --skip-hash-check=true to restore command…which works perfectly…

  1. –data-dir value needs to be changed only in volumes.hostPath , no need to change in command option and volumeMounts section at all. This is working for me, Did somebody tried this ? if so, any comments ?

let me know if this is not right…