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 #svcIP=$(kubectl get svc | grep nginx |grep -i "nodeport" | awk -F'[ ]+' '{print $3}')
21 #echo "Service IP:"$svcIP
22 #nodePort=$(kubectl get svc | grep nginx |grep -i "nodeport" | awk -F'[ ]+' '{print $5}' | cut -d ":" -f 2 |cut -d "/" -f 1)
23 #echo "NodePort:"$nodePort
26 ARGS=`getopt -a -o s:n:c:p:k::h:: -l nodeIP:,number:,serviceIP:,nodePort:,nodeOnly::,help:: -- "$@"`
38 echo "access number=$2"
53 echo "Ignore accessing service IP test."
57 echo "this is help case"
63 echo "Use default args, now do the test:"
73 if [[ "x${svcIP}" == "x" && ${onlyNode} != "true" ]]; then
74 echo "No service IP defined, try to find locally:"
75 svcIP=$(kubectl get svc | grep nginx |grep -i "nodeport" | awk -F'[ ]+' '{print $3}')
76 echo "Service IP:"$svcIP
79 if [ "x${nodePort}" == "x" ]; then
80 echo "No nodePort defined, try to find locally:"
81 nodePort=$(kubectl get svc | grep nginx |grep -i "nodeport" | awk -F'[ ]+' '{print $5}' | cut -d ":" -f 2 |cut -d "/" -f 1)
82 echo "NodePort:"$nodePort
86 accessNum=$((aNum + 0))
87 #for i in {1..$(($aNum + 0))}
92 if [ "x${nodeOnly}" != "xtrue" ]; then
93 echo "Now access the service IP $svcIP:80, $aNum times:"
94 for (( c=$START; c<=$END; c++))
96 curl -w "%{time_total}\n" -o /dev/null -s http://$svcIP
97 done | jq -s add/length
101 echo "Now access the $nodeIP:$nodePort, $aNum times"
102 for (( c=$START; c<=$END; c++))
104 curl -w "%{time_total}\n" -o /dev/null -s $nodeIP:$nodePort
105 done | jq -s add/length