Skip to content

Instantly share code, notes, and snippets.

@tamalsaha
Last active September 21, 2017 05:56
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tamalsaha/4e6a5c1144e2daf370398520e20fdef7 to your computer and use it in GitHub Desktop.
Save tamalsaha/4e6a5c1144e2daf370398520e20fdef7 to your computer and use it in GitHub Desktop.
Kubectl exec with working terminal
#!/bin/sh
if [ "$1" = "" ]; then
echo "Usage: ksh <pod> [flags_to_kubectl]"
exit 1
fi
POD=$1
shift
COLUMNS=`tput cols`
LINES=`tput lines`
TERM=xterm
KUBE_SHELL=${KUBE_SHELL:-bash}
kubectl exec -i -t $POD "$@" -- env COLUMNS=$COLUMNS LINES=$LINES TERM=$TERM "$KUBE_SHELL"
@tamalsaha
Copy link
Author

Thanks @coresolve !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment