0
我用下面的代碼來隨機地殺死莢內部過程Kuberntes殺過程內莢
: ${DELAY:=30}
if [ "$#" -ne 1 ]; then
echo "One argument expected specifying the time in seconds to run"
else
end=$((SECONDS+$1))
while [ $SECONDS -lt $end ]; do
kubectl \
-o 'jsonpath={.items[*].metadata.name}' \
get 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) is greater than time specified in argument
# sleep "${DELAY}" #sleep so that pod gets completely deleted and a terminating pod not selecte
#else
# break
#fi
done
fi
腳本運行,但沒有顯示輸出在它進入一些無限循環。有人能幫助我出錯嗎?
是的,謝謝:)請試試看! –