-
-
Save jamesholcomb/b642f3459c203836f59aee2e0528e46c to your computer and use it in GitHub Desktop.
A shell script which enables easy execing into kube pods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ "$1" = "" ]; then | |
echo "Usage: ./ksh <pod>" | |
exit 1 | |
fi | |
echo Getting pods... | |
PODS=$(kubectl get pods --no-headers --output=name | grep $1) | |
PODS=(${PODS}) | |
NUM_PODS=${#PODS[@]} | |
if [ $NUM_PODS -gt 1 ]; then | |
echo Choose a pod: | |
select pod in "${PODS[@]}" | |
do | |
POD=${pod/pods\//} | |
break | |
done | |
else | |
POD=${PODS[0]/pods\//} | |
fi | |
echo Connecting to $POD... | |
COLUMNS=`tput cols` | |
LINES=`tput lines` | |
TERM=xterm | |
kubectl exec -it $POD env COLUMNS=$COLUMNS LINES=$LINES TERM=$TERM bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment