Add script to get etcd info (#22588)

Signed-off-by: zhuwenxing <wenxing.zhu@zilliz.com>
This commit is contained in:
zhuwenxing 2023-03-07 10:26:01 +08:00 committed by GitHub
parent f3e2d4a39a
commit 2ad441e3b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,16 @@
#!/bin/bash
instance_name=$1
# Define the etcdctl command with endpoints option
etcdctl_cmd="etcdctl endpoint status -w table --endpoints"
# Get the ip of all the etcd pods with the specified labels
etcd_pods=$(kubectl get pods -l app.kubernetes.io/name=etcd,app.kubernetes.io/instance=${instance_name} -o jsonpath='{.items[*].status.podIP}')
# Loop through the list of etcd pods and get their status
endpoints=""
for pod in $etcd_pods
do
endpoints+="$pod:2379,"
done
$etcdctl_cmd ${endpoints::-1}