From f8e206c372027ca5b513545c880a23b63de8778a Mon Sep 17 00:00:00 2001 From: Magnus Andersson Date: Wed, 23 Oct 2024 13:44:02 +0200 Subject: [PATCH] Add script to test connectivity between k8s nodes --- tools/k8sconnectivitytest.sh | 58 ++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100755 tools/k8sconnectivitytest.sh diff --git a/tools/k8sconnectivitytest.sh b/tools/k8sconnectivitytest.sh new file mode 100755 index 0000000..d9c73a4 --- /dev/null +++ b/tools/k8sconnectivitytest.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +declare -A portsw +portsw['4789']='udp' +portsw['10250']='tcp' +portsw['10255']='tcp' +portsw['10257']='tcp' +portsw['10259']='tcp' +portsw['12379']='tcp' +portsw['16443']='tcp' +portsw['25000']='tcp' +portsw['51820']='udp' + +declare -A portsc +portsc['4789']='udp' +portsc['10250']='tcp' +portsc['10255']='tcp' +portsc['10257']='tcp' +portsc['10259']='tcp' +portsc['12379']='tcp' +portsc['16443']='tcp' +portsc['25000']='tcp' +portsc['51820']='udp' + + + +declare -a hostsw +hostsw+=('k8sw1.matrix.test.sunet.se') +hostsw+=('k8sw2.matrix.test.sunet.se') +hostsw+=('k8sw3.matrix.test.sunet.se') +hostsw+=('k8sw4.matrix.test.sunet.se') +hostsw+=('k8sw5.matrix.test.sunet.se') +hostsw+=('k8sw6.matrix.test.sunet.se') + +declare -a hostsc +hostsc+=('k8sc1.matrix.test.sunet.se') +hostsc+=('k8sc2.matrix.test.sunet.se') +hostsc+=('k8sc3.matrix.test.sunet.se') + +echo "*** Test k8s port conectivity to worker nodes ***\n" + +for h in ${hostsw[@]}; do + for po in ${!portsw[@]}; do + [[ "${portsw[$po]}" == "udp" ]] && pr="-u " || pr="" + timeout -k 2 1 nc -vz ${pr}${h} ${po} 2>/dev/null && echo "${h} ${po}/${portsw[$po]^^} [SUCESS]" || echo "${h} ${po}/${portsw[$po]^^} [FAILURE]" + done + echo "" +done + +echo -e "*** Test K8s port connectivity to control nodes ***\n" + +for h in ${hostsc[@]}; do + for po in ${!portsc[@]}; do + [[ "${portsc[$po]}" == "udp" ]] && pr="-u " || pr="" + timeout -k 2 1 nc -vz ${pr}${h} ${po} 2>/dev/null && echo "${h} ${po}/${portsc[$po]^^} [SUCESS]" || echo "${h} ${po}/${portsc[$po]^^} [FAILURE]" + done + echo "" +done