3 localIP=$(ip route show default | cut -d " " -f 9)
4 echo "localIP:"$localIP
6 if [ "x${1}" == "x" ]; then
7 echo "No node IP defined, uses the local IP instead."
17 echo "Please input the nodeIP and access number"
20 ARGS=`getopt -a -o s:n:h -l nodeIP:,number:,help -- "$@"`
32 echo "access number=$2"
36 echo "this is help case"
40 echo "Now do the test:"
49 svcIP=$(kubectl get svc | grep nginx |grep -i "nodeport" | awk -F'[ ]+' '{print $3}')
50 echo "Service IP:"$svcIP
51 nodePort=$(kubectl get svc | grep nginx |grep -i "nodeport" | awk -F'[ ]+' '{print $5}' | cut -d ":" -f 2 |cut -d "/" -f 1)
52 echo "NodePort:"$nodePort
54 accessNum=$((aNum + 0))
55 echo "Now access the service IP, $aNum times:"
56 #for i in {1..$(($aNum + 0))}
60 for (( c=$START; c<=$END; c++))
62 curl -w "%{time_total}\n" -o /dev/null -s http://$svcIP
63 done | jq -s add/length
65 echo "Now access the NodePort, $aNum times"
66 for (( c=$START; c<=$END; c++))
68 #curl -w "%{time_total}\n" -o /dev/null -s http://10.169.210.208:31942
69 #curl -w "%{time_total}\n" -o /dev/null -s http://10.169.210.208:31942
70 curl -w "%{time_total}\n" -o /dev/null -s $localIP:$nodePort
71 done | jq -s add/length