Victor:
Worst part is cant decide when to use – and when not. (k create namespace test) works fine, it should be but k create --namespace=test Any one can please explain
Rob Thorne:
No, you got it right the first time. k create
has sub-commands, and k create namespace
is one of the sub-commands.
Alistair Mackay:
Commands and subcommands are just words. Arguments (switches) have dashes.
When creating a namespace namespace
is the subcommand of create
- i.e. what are we creating?
Command: create
Subcommand namespace
When listing pods, then namespace is an argument
Command: get
Subcommand pods
Argument: --namespace
- which namespace do we want to “get” “pods” for?
Victor:
and difference between single and double dash
Ron Chmara:
A very-popular-but-not-universal convention is that short versions of arguments have one dash, longer versions have two.
They are often the same case, and same letter, but not always.
-n
is --namespace
-h
is --help
-A
is--all-namespaces
(upper and lower case)
-l
is --selector
(different letter)
(etc.)
Things that are typed very frequently tend to have single dash+letter shortcuts.
Combining methods, on a system <https://kubernetes.io/docs/reference/kubectl/cheatsheet/|with autocomplete>, and using the kubectl short names, and the k alias, this"
k get po,svc,pvc -n kube-s<tab> -o wide
is the same as typing out:
kubectl get pods,services,persistentvolumeclaims --namespace=kube-system --output wide
Many less characters to type in the first one, after all the shortcuts are memorized, and using <tab> to finish typing becomes second nature.