#Simple script to test all the pods liveness/readiness #creates portforward and curls the endpoint for status #clears the portforward at the end of the script #uses bash v3 based implementation. #Test only the pods which are up. #!/bin/bash aggregate_feed="tfeed" aggregates=( "app1:7101" "app2:7102" "app3:7103" ) k="kubectl" for item in "${aggregates[@]}"; do key=${item%%:*} port=${item#*:} name="test-${key}-${aggregate_feed}-0" echo -e "\n\n$name -> $port" pod_name=$($k get pods |grep Running|awk "/$key-${aggregate_feed}/{print $1}"|head -1|cut -d " " -f1) if [[ ! -z ${pod_name} ]]; then echo "POD: $pod_name" $k port-forward ${name} ${port}:${port} & &>/dev/null sleep 3 curl http://localhost:${port}/${key}-${aggregate_feed}/health/readiness else echo "${name}: Pod Not Found" fi done echo "" killall kubectl 2>&1 > /dev/null