-
-
Save eplord/67370a71fef84c8f51e2b9a9cbf5f79a to your computer and use it in GitHub Desktop.
This file contains hidden or 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/zsh | |
| # expects https://github.com/ahmetb/kubectl-aliases | |
| # implements lots of https://kubernetes.io/docs/reference/kubectl/cheatsheet/ | |
| alias kgpos='kgpo --sort-by=.metadata.creationTimestamp' | |
| alias kgpoy='kgpo -o yaml' | |
| ### config view | |
| alias kcv='k config' | |
| alias kcv='kc view' | |
| ### users | |
| alias kusers="kcv -o jsonpath='{.users[*].name}'" | |
| kuser() { kcv -o jsonpath='{.users[?(@.name == "'"${1:-${USER:-$(whoami)}}"'")].user.password}'; } | |
| alias kusers="kcv -o jsonpath='{.users[*].name}'" | |
| kuser() { kcv -o jsonpath='{.users[?(@.name == "'"${1:-${USER:-$(whoami)}}"'")].user.password}'; } | |
| ### exec | |
| alias kx='k exec' | |
| alias kxit='kx -it' | |
| kxls() { local rest="${@:2}"; kx ${1:-my-pod} -- ls ${rest:-/}; } | |
| alias kls=kxls | |
| kxlsx() { local rest="${@:3}"; kx ${1:-my-pod} -c ${2:-my-container} -- ls ${rest:-/}; } | |
| ### logs | |
| klbl() { local rest="${@:2}"; klo -l name=${1:-my-label} ${rest}; } | |
| klprev() { local rest="${@:2}"; klo ${1} --previous ${rest}; } | |
| klblc() { local rest="${@:3}"; klbl ${1:-my-label} -c ${2:-my-container} ${rest}; } | |
| alias klblcp='klblc --previous' | |
| ### port-forward | |
| alias kpf='kubectl port-forward' | |
| kfwd() { kpf ${1:-my-pod} ${2:-8000}:${3:-${2:-8000}}; } | |
| ### run | |
| alias kr='k run' | |
| alias krun='kr busybox-test --image=busybox -it --rm --restart=Never --' | |
| alias kash='krun /bin/ash' | |
| ### top | |
| alias ktop='k top' | |
| ktpod() { ktop pod ${1:-my-pod} --containers; } | |
| ktnod() { ktop node ${1:-my-node}; } | |
| alias ktnode=ktnod | |
| ### attach | |
| alias katt='k attach -i' | |
| ### api-resources | |
| alias kapi='k api-resources --sort-by=kind' | |
| alias kapiny='kapi --namespaced=true' | |
| alias kapino='kapi --namespaced=false' | |
| alias kapiw='kapi -o wide' | |
| alias kapir='kapiw --verbs=list,get' | |
| ### cluster | |
| alias kcl='k cluster-info' | |
| alias kcld='kcl dump' | |
| ### misc | |
| alias kapp='k apply' | |
| alias kdel='k delete' | |
| alias kgen='k --dry-run=client -o yaml' # for creating manifests. e.g. kman run nginx --image=nginx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment