From 2ad441e3b98eb00592eaba1535d1490e82fdf274 Mon Sep 17 00:00:00 2001 From: zhuwenxing Date: Tue, 7 Mar 2023 10:26:01 +0800 Subject: [PATCH] Add script to get etcd info (#22588) Signed-off-by: zhuwenxing --- tests/scripts/get_etcd_info.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 tests/scripts/get_etcd_info.sh diff --git a/tests/scripts/get_etcd_info.sh b/tests/scripts/get_etcd_info.sh new file mode 100644 index 000000000..de73f23b6 --- /dev/null +++ b/tests/scripts/get_etcd_info.sh @@ -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} \ No newline at end of file -- GitLab