Skip to content

Instantly share code, notes, and snippets.

@larte
Created February 28, 2017 19:00
Show Gist options
  • Save larte/acc874f62ac78c0962c840798ec00216 to your computer and use it in GitHub Desktop.
Save larte/acc874f62ac78c0962c840798ec00216 to your computer and use it in GitHub Desktop.
Kubernetes execute shell wrapper
#compdef ksh
# command completion for zsh
typeset -A opt_args
_arguments -C \
'1:pod:->pods' \
'*:: :->args' \
&& ret=0
case "$state" in
(pods)
local pods; pods=(
`kubectl get po --no-headers -o=custom-columns=Name:.metadata.name`
)
_describe -t pods 'pod' pods && ret=0
;;
(args)
local options; options=(
'--namespace='
'--container='
)
_describe -t options 'options' options && ret=0
;;
esac;
return 1
#!/bin/sh
COLUMNS=`tput cols`
LINES=`tput lines`
TERM=xterm
KUBE_SHELL=${KUBE_SHELL:-bash}
POD=$1
shift
kubectl exec -it $POD "$@" -- env COLUMNS=$COLUMNS LINES=$LINES TERM=$TERM "$KUBE_SHELL"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment