saip:
As you can see in the first command in my output above it worked ok.
Kratik Jain:
I am not saying anything about -it ,
Just use sh -c "WHOLE COMMAND" and you’ll be good to go
saip:
Yeah I get you.
saip:
Got rid of the previous messages that I put here for simplicity. I see what you mean about the usage of “=” in the command.
Kratik Jain:
The -c argument is: Read commands from the command_string operand instead of from the standard input.
saip:
Well the bit which really got me puzzled here is the whole backup works when I do this : kubectl -n kube-system exec etcd-k8s-master – 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
saip:
That is why I said if etcd has changed with 3.4. I will rephrase my question for acrhiving purposes.
saip:
@Kratik Jain I tested it again and above command works like charm, at least in kubeadm based setup where etcd is a pod. So even without ETCDCTL_API=3 parameter it is always able to save the backup.
saip:
Well I found the answer, it has changed. API version is 3 by default with ETCD 3.4.0 : https://chromium.googlesource.com/external/github.com/coreos/etcd/+/refs/heads/master/CHANGELOG-3.4.md#breaking-changes
saip:
@Mumshad Mannambeth @Rahul Soni It would be great if this can be updated in the training for new people. ^^
Kratik Jain:
@saip can you try etcdctl version command as you tried above command,
If it’s ETCDCTL_API=3 , it will print the version otheriwise it will throw error.
saip:
I did that already, it is in my first message ^^^
saip:
Still pasting it here :
saip:
k8s-master:~$ kubectl -n kube-system exec etcd-k8s-master – etcdctl version
etcdctl version: 3.4.3
API version: 3.4
Kratik Jain:
Cool man, No need… Got You! ![]()
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