when match multiple element,kexec will waiting

This commit is contained in:
hophacker 2019-06-07 18:51:43 +08:00
parent 07390f657f
commit 2722ecd9f0

View File

@ -155,7 +155,17 @@ function h() {
}
function kexec {
TEXT=$1
POD_NAME=`k get pods | grep $TEXT | awk '{print $1}'`
echo 'waiting...'
while true; do
POD_NAME=`k get pods | grep $TEXT | awk '{print $1}'`
array=("${(f)POD_NAME}")
echo ${array[@]}
if [ ${#array[@]} -ne 1 ];then
sleep 2
else
break
fi
done
shift 1
kubectl exec -it $POD_NAME $@
}