Created
November 26, 2020 09:48
-
-
Save hemanthnakkina-zz/e2403a375b9fc124d5993021d2db3cc6 to your computer and use it in GitHub Desktop.
Query etcd keys
This file contains 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
#!/bin/bash -eux | |
# This file is based on https://code.launchpad.net/~freyes/+git/experiment | |
# Modified to use xargs instead of parallel | |
# 'etcd.etcdctl' is provided by the etcd snap | |
which etcd.etcdctl | |
PARALLEL_REQS=20 | |
SLEEP_SECS=0.1 | |
KEY="/registry/services/endpoints/kube-system/kube-controller-manager" | |
TEMPLOG=$(mktemp).log | |
[[ $(cat /var/snap/kube-apiserver/current/args) =~ --etcd-servers=(.[^ ]+) ]] | |
ETCD_ENDPOINTS=${BASH_REMATCH[1]} | |
echo "logging to $TEMPLOG" | |
echo "etcd endpoints: $ETCD_ENDPOINTS" | |
# trap ctrl-c and call ctrl_c() | |
trap ctrl_c INT | |
function ctrl_c() { | |
local DEST=query-etcd.$(date '+%Y%m%d_%H%M').log | |
mv $TEMPLOG $DEST | |
echo "output at $DEST" | |
exit 0 | |
} | |
set +x | |
while true; do | |
seq $PARALLEL_REQS | xargs -I {} -P$PARALLEL_REQS sudo etcd.etcdctl --cacert /root/cdk/etcd/client-ca.pem --cert /root/cdk/etcd/client-cert.pem --key /root/cdk/etcd/client-key.pem --endpoints=$ETCD_ENDPOINTS get -w json $KEY 2>&1 >> $TEMPLOG | |
/bin/sleep $SLEEP_SECS | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment