From 881dc244b16673a7e81ec831d65a621dbd946863 Mon Sep 17 00:00:00 2001 From: Hari Sekhon Date: Fri, 9 Apr 2021 18:39:12 +0100 Subject: [PATCH] updated kubectl_busybox.sh --- kubectl_busybox.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kubectl_busybox.sh b/kubectl_busybox.sh index e5eb14b7..53ac4762 100755 --- a/kubectl_busybox.sh +++ b/kubectl_busybox.sh @@ -33,9 +33,11 @@ usage_args="[]" help_usage "$@" -name=busybox +name="busybox-$USER" -if kubectl get po "$name" "$@" &>/dev/null; then +if kubectl get po "$name" "$@" -o json 2>/dev/null | + jq -r 'select(.status.phase == "Running")' | + grep -q . &>/dev/null; then kubectl exec -ti "$name" "$@" -- /bin/sh else kubectl run -ti --rm --restart=Never "$name" --image=busybox "$@" -- /bin/sh