#!/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