Question 26
Domain 1: Cluster Architecture, Installation & ConfigurationWhich kubectl command is used to retrieve the value of the key `cluster.name` from etcd and create an etcd backup?
Correct answer: A
Explanation
`etcdctl get cluster.name` retrieves the value for the key, since the command is used to “get” a key from etcd. `ETCDCTL_API=3 etcdctl snapshot save <backup-file>` creates the backup because the snapshot command saves a point-in-time copy of the etcd data.
Why each option is right or wrong
A. Use `ETCDCTL_API=3 etcdctl get cluster.name --endpoints=<etcd-endpoint>` and then `ETCDCTL_API=3 etcdctl snapshot save <backup-file>`
Under the etcd v3 API, the client command for reading a specific key is `etcdctl get`, so `ETCDCTL_API=3 etcdctl get cluster.name --endpoints=<etcd-endpoint>` is the correct way to query that key from the live datastore. A backup is taken with `etcdctl snapshot save <backup-file>`, which writes a point-in-time snapshot of the entire etcd database to the named file; the `ETCDCTL_API=3` prefix is required because snapshot operations are performed with the v3 client interface.
B. Use `kubectl get configmap cluster.name -o yaml` and then `kubectl backup etcd --all-namespaces`
C. Use `etcdctl list cluster.name` and then `etcdctl export backup <backup-file>`
D. Use `kubectl exec etcd -- get cluster.name` and then `kubectl cp /var/lib/etcd <backup-file>`