You will type kubectl thousands of times. Three shortcuts save most of the typing.
Short names
Every kind has a short name. These are the ones you already know:
| Kind | Short name |
|---|---|
| pods | po |
| namespaces | ns |
| nodes | no |
learner@shallows:~$ kubectl get po -n shopThe full list is in the cluster. api-resources prints every kind with its short name, its API version, and whether it lives in a namespace:
learner@shallows:~$ kubectl api-resources
NAME SHORTNAMES APIVERSION NAMESPACED KIND
namespaces ns v1 false Namespace
nodes no v1 false Node
pods po v1 true PodYou can also ask for several kinds at once:
learner@shallows:~$ kubectl get po,noThe k alias
Almost everyone shortens kubectl to k:
learner@shallows:~$ alias k=kubectl
learner@shallows:~$ k get po -AThe alias lasts for this shell. Chapter 12 of Linux Essentials shows how to keep one. This course writes kubectl in full so that every line is copyable; use k whenever you type by hand.
--help
Every verb explains its own flags:
learner@shallows:~$ kubectl get --help
learner@shallows:~$ kubectl run --helpIt is faster than a search, and it matches the version you are running. When a lab asks for a flag you half remember, --help first.