ETCD Backup and Restore Issue

Kratik Jain:
Cool man, No need… Got You! :slightly_smiling_face:

saip:
Well thank you. If you did not jump in I also would never have thought that it is the command string (ie = ) that is causing the issue.

Srujan mettu:
@Rahul Soni can you please suggest how do we take the backup in exam with the current version v.1.18?

[root@kmaster ~]# kubectl exec etcd-kmaster -n kube-system – etcdctl version
etcdctl version: 3.4.3
API version: 3.4

Srujan mettu:
[root@kmaster ~]# ETCDCTL_API=3
[root@kmaster ~]#
[root@kmaster ~]#
[root@kmaster ~]#
[root@kmaster ~]# ETCDCTL_API=3 etcdctl snapshot save -h
bash: etcdctl: command not found…

Srujan mettu:
[root@kmaster ~]# kubectl exec etcd-kmaster -n kube-system – etcdctl snapshot save --cacert=/etc/kubernetes/pki/etcd/ca.crt --cert=/etc/kubernetes/pki/etcd/server.crt --endpoints=https://10.0.0.16:2379 --key=/etc/kubernetes/pki/etcd/server.key /opt/test.db
{“level”:“info”,“ts”:1590679946.1462595,“caller”:“snapshot/v3_snapshot.go:110”,“msg”:“created temporary db file”,“path”:“/opt/test.db.part”}
{“level”:“warn”,“ts”:“2020-05-28T15:32:26.148Z”,“caller”:“clientv3/retry_interceptor.go:116”,“msg”:“retry stream intercept”}
{“level”:“info”,“ts”:1590679946.1488469,“caller”:“snapshot/v3_snapshot.go:121”,“msg”:“fetching snapshot”,“endpoint”:“https://10.0.0.16:2379”}
{“level”:“info”,“ts”:1590679946.2232032,“caller”:“snapshot/v3_snapshot.go:134”,“msg”:“fetched snapshot”,“endpoint”:“https://10.0.0.16:2379”,“took”:0.076767641}
{“level”:“info”,“ts”:1590679946.2233112,“caller”:“snapshot/v3_snapshot.go:143”,“msg”:“saved”,“path”:“/opt/test.db”}
Snapshot saved at /opt/test.db

Srujan mettu:
i tried this way but not sure this is correct in exam prespective?

Chinnasamy Uvaraja:
@Mumshad Mannambeth @Rahul Soni could you please clarify as it’s going to impact candidates scoring and potentially deciding factor of exam results.
I saw one of the post where one of the candidate struggled coz of this issue.
Thanks in advance.

saip:
Guys there is not much to make a big deal out of this. All I mentioned here is with ETCD 3.4.3 the API version is set to 3 by default. So NO need to use etcdctl_api=3 stuff…

saip:
This topic was more focused on how you can execute the command if your etcd is a pod rather than a process. In kubeadm based setups it is a pod and I just dont know if ALL the labs in the exam are kubeadm based or not.

saip:
My mistake when I was trying to run the commands on the etcd pod was as @Kratik Jain mentioned, the “=” in the string is not properly processed. So using — sh -c “….” works.

Kratik Jain:
Hi @saip
See this Deprecated etcd --ca-file flag. Use etcd --trusted-ca-file instead (etcd --ca-file flag has been marked deprecated since v2.1).
Found In the changelog you shared.

Ron:
Can someone please confirm if we can use this for v.1.18

Ron:
kubectl -n kube-system exec etcd-ansible-control – etcdctl --cacert=/etc/kubernetes/pki/etcd/ca.crt --cert=/etc/kubernetes/pki/etcd/server.crt --key=/etc/kubernetes/pki/etcd/server.key --endpoints=127.0.0.1:2379 snapshot save /opt/test.db

[root@ansible-control opt]# kubectl -n kube-system exec etcd-ansible-control – etcdctl --cacert=/etc/kubernetes/pki/etcd/ca.crt --cert=/etc/kubernetes/pki/etcd/server.crt --key=/etc/kubernetes/pki/etcd/server.key --endpoints=127.0.0.1:2379 --write-out=table snapshot status /opt/test.db
±---------±---------±-----------±-----------+
| HASH | REVISION | TOTAL KEYS | TOTAL SIZE |
±---------±---------±-----------±-----------+
| 8090c080 | 32974944 | 1202 | 3.1 MB |
±---------±---------±-----------±-----------+
[root@ansible-control opt]#