Last active
November 18, 2025 07:43
-
-
Save mjbright/0b12daf273a77a2925e2bf7cbf2be31b to your computer and use it in GitHub Desktop.
Easy access to etcdctl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Function to simplify use of etcdctl from cp Node | |
| # | |
| # - set POD to the Pod name for etcd on a Node: | |
| # - then try one of the commands: | |
| # etcdctl member list | |
| # etcdctl member list -w table | |
| # etcdctl member list -w table | |
| # etcdctl endpoint health | |
| # etcdctl endpoint status -w table | |
| # | |
| function etcdctl { | |
| [ -z "$1" ] && set -- endpoint status -w table | |
| echo "Running on $(hostname) [$(hostname -i)]" | |
| # SET this value as appropriate: | |
| POD=etcd-cp | |
| case $(hostname) in | |
| cp) POD=etcd-cp;; | |
| secondcp|cp2) POD=etcd-secondcp;; | |
| thirdcp|cp3) POD=etcd-thirdcp;; | |
| esac | |
| # NOTE: ETCDCTL_API=3 is no longer needed after Kubernetes 1.34 | |
| kubectl --request-timeout='1' -n kube-system exec -it $POD -- sh -c \ | |
| "ETCDCTL_API=3 ETCDCTL_CACERT=/etc/kubernetes/pki/etcd/ca.crt ETCDCTL_CERT=/etc/kubernetes/pki/etcd/server.crt ETCDCTL_KEY=/etc/kubernetes/pki/etcd/server.key etcdctl $*" | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
etcdcl_all.fn
Here's a version for use with an HA cluster.
Note the
-loption which loops every 2 seconds