Your most important shell alias for Kubernetes

I have been on a mission as of late to use more shell aliases, and Matt Tucker at the last Kubernetes meetup, in Boulder, reminded me of huge time savers for kubectl/Kubernetes users.

Here is the fantastic time saver that needs to be in your shell profile:

alias k=kubectl

For those who are not familiar, kubectl is the command line interface tool for running commands against Kubernetes clusters. Most K8s users use kubectl a lot.

As mentioned in the kubectl cheat sheet, kubectl supports autocomplete in both the bash and zsh shells.

# setup autocomplete in bash, bash-completion package should be installed first.
source <(kubectl completion bash)
# setup autocomplete in zsh
source <(kubectl completion zsh)
# for help on setting up autocomplete
kubectl completion -h

For those who want to have more aliases here are 600 for your viewing pleasure: https://github.com/ahmetb/kubectl-aliases.

A humorous story, one of the bugs I found in the PetSet documentation was that the author documented using k instead of the kubectlcommand.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply