Seems like with etcdctl 3.4.3 there is no need to specify ETCDCTL_API=3 parameter ? I instantiated a 1.18 cluster with kubeadm and the etcd pod does not accept any of the commands that starts with ETCDCTL_API=3 ?
k8s-master:~ kubectl -n kube-system exec etcd-k8s-master -- etcdctl version etcdctl version: 3.4.3 API version: 3.4 k8s-master:~ kubectl -n kube-system exec -it etcd-k8s-master – ETCDCTL_API=3 etcdctl --help
OCI runtime exec failed: exec failed: container_linux.go:349: starting container process caused “exec: \“ETCDCTL_API=3\“: executable file not found in PATH”: unknown command terminated with exit code 126 k8s-master:~
Any thoughts ?
It’s not like you don’t need to specify
Afaik and Whatever the examples I have seen It needs to be declared,
One of basic difference(The command to check version)
The issue in your command is not anywhere related to k8s - I don’t know what exactly it is termed(maybe other experts can let us know!) but it is how you input your commands to the underlying container (after
I guess as your command includes
-- (in --help) which are leading your command to not get passed properly.
to pass your command properly try this
kubectl -n kube-system exec -it etcd-k8s-master -- sh -c "ETCDCTL_API=3 etcdctl --help"
this will pass your all commands and args properly
I always use just “–” and after that the command itself… Dont think we need “-it” here cause I dont need to attach to the terminal of the pod.
As you can see in the first command in my output above it worked ok.
I am not saying anything about
sh -c "WHOLE COMMAND" and you’ll be good to go
Yeah I get you.
Got rid of the previous messages that I put here for simplicity. I see what you mean about the usage of “=” in the command.
The -c argument is: Read commands from the command_string operand instead of from the standard input.
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
That is why I said if etcd has changed with 3.4. I will rephrase my question for acrhiving purposes.
@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.
@Rahul Soni are you aware of any changes with etcd 3.4 ?
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
@Mumshad Mannambeth @Rahul Soni It would be great if this can be updated in the training for new people. ^^
@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.
I did that already, it is in my first message ^^^
Still pasting it here :
k8s-master:~$ kubectl -n kube-system exec etcd-k8s-master – etcdctl version
etcdctl version: 3.4.3
API version: 3.4