Using shell aliases for kubectl commands
Typing kubectl
with a command every time is both boring and time-consuming. You can use kubectl
command completion in the Bash
and Zsh
shells, which helps of course, but it is still not as quick as using aliases.
Let's overview a list of some handy kubectl
commands and use them with aliases that you can put in the zsh_aliases
or bash_aliases
files, depending on which shell you are using:
k
forkubectl
—this speaks for itself.kg
forkubectl get
—this is useful to get a list of pods, deployments, statefulsets, services, nodes, and other details, as shown in the following example command:$ kg nodes
The output of the preceding command is shown in the following screenshot:
The preceding screenshot shows a list of available Kubernetes nodes in the cluster by running the $ kg nodes
command.
kd
forkubectl describe
—this is useful to describe...