From 2722ecd9f0b77a1e17265e82312527122bde1076 Mon Sep 17 00:00:00 2001 From: hophacker Date: Fri, 7 Jun 2019 18:51:43 +0800 Subject: [PATCH] when match multiple element,kexec will waiting --- zsh/functions.zsh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/zsh/functions.zsh b/zsh/functions.zsh index 8ffb17d..628647b 100644 --- a/zsh/functions.zsh +++ b/zsh/functions.zsh @@ -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 $@ }