bash - Kuberntes kill process inside pod -
i using following code randomly kill processes inside pods
: ${delay:=30} if [ "$#" -ne 1 ]; echo "one argument expected specifying time in seconds run" else end=$((seconds+$1)) while [ $seconds -lt $end ]; kubectl \ -o 'jsonpath={.items[*].metadata.name}' \ pods | \ tr " " "\n" | \ shuf | \ head -n 1 | #xargs -t --no-run-if-empty \ kubectl exec $(head -n 1) -- kill -9 9 #if [ $((seconds+${delay})) -lt $end ];then #break loop if (seconds completed + delay) greater time specified in argument # sleep "${delay}" #sleep pod gets deleted , terminating pod not selecte #else # break #fi done fi
the script runs no output shown in goes infinite loop. can going wrong?
two things: -o 'jsonpath={.items[*].metadata.name}'
should go after kubectl pods
, otherwise kubectl return message. also, add -t kubectl exec
in order see output container in terminal.
Comments
Post a Comment