Why do I need to put ETCDCTL_API=3 in front of etcdctl for etcdctl snapshot save to work? Why do I need to put ETCDCTL_API=3 in front of etcdctl for etcdctl snapshot save to work? kubernetes kubernetes

Why do I need to put ETCDCTL_API=3 in front of etcdctl for etcdctl snapshot save to work?


Well it turned out to be a lack of Linux knowledge. When I was following a few Kubernetes how to guides I used Bash variables all the time, what I didn't realize is that there's a difference between normal variables an environment variables.

I was doing:

ETCDCTL_API=3 echo $ETCDCTL_API3

And it looked right, but then I remembered the printenv command, and I didn't see what I expected, that's when I figured out there was a difference between environment variables and regular variables.

I had to add export in front of the variable statement, to make it an environment variable.

What's really cool is that after reading this
https://github.com/etcd-io/etcd/blob/master/etcdctl/README.md

I was able to make the above, become nice short commands like this:

export ETCDCTL_API=3export ETCDCTL_CACERT=/etc/etcd/ca.pemexport ETCDCTL_CERT=/etc/etcd/kubernetes.pemexport ETCDCTL_KEY=/etc/etcd/kubernetes-key.pemetcdctl member list --endpoints=https://127.0.0.1:2379 etcdctl snapshot save ~/etcd.backup