From c4415a89fa2831fce16ce081e29edb5446752783 Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Sun, 17 Jan 2021 15:31:07 +0800 Subject: [PATCH] [feature] working with k8s pod easily --- bin/kp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 bin/kp diff --git a/bin/kp b/bin/kp new file mode 100755 index 0000000..0d178e2 --- /dev/null +++ b/bin/kp @@ -0,0 +1,16 @@ +#!/bin/sh + +POD=$(sudo kubectl get pod | grep -P "^$2" | awk '{print $1}') +CTN=$3 + + +case $1 in + sh) + kubectl exec -it $POD ${CTN+"-c$CTN"} -- sh + ;; + d) # describe pod + kubectl describe pod $POD + ;; + e) # watch event of pod + kubectl get event -w --field-selector=involvedObject.name=$POD +esac