3 localIP=$(ip route show default | cut -d " " -f 9)
4 echo "localIP:"$localIP
7 if [ "x${1}" == "x" ]; then
8 echo "No node IP defined, uses the local IP instead."
17 echo "Please input the nodeIP and access number"
21 ARGS=`getopt -a -o s:n:c:p:k::h:: -l nodeIP:,number:,serviceIP:,nodePort:,nodeOnly::,help:: -- "$@"`
33 echo "access number=$2"
48 echo "Ignore accessing service IP test."
52 echo "this is help case"
58 echo "Use default args, now do the test:"
68 if [[ "x${svcIP}" == "x" && ${onlyNode} != "true" ]]; then
69 echo "No service IP defined, try to find locally:"
70 svcIP=$(kubectl get svc | grep nginx |grep -i "nodeport" | awk -F'[ ]+' '{print $3}')
71 echo "Service IP:"$svcIP
74 if [ "x${nodePort}" == "x" ]; then
75 echo "No nodePort defined, try to find locally:"
76 nodePort=$(kubectl get svc | grep nginx |grep -i "nodeport" | awk -F'[ ]+' '{print $5}' | cut -d ":" -f 2 |cut -d "/" -f 1)
77 echo "NodePort:"$nodePort
80 accessNum=$((aNum + 0))
84 if [ "x${nodeOnly}" != "xtrue" ]; then
85 echo "Now access the service IP $svcIP:80, $aNum times:"
86 for (( c=$START; c<=$END; c++))
88 curl -w "%{time_total}\n" -o /dev/null -s http://$svcIP
89 done | jq -s add/length
93 echo "Now access the $nodeIP:$nodePort, $aNum times"
94 for (( c=$START; c<=$END; c++))
96 curl -w "%{time_total}\n" -o /dev/null -s $nodeIP:$nodePort
97 done | jq -s add/length