Is there any alias we can make for all-namespace as kubectl don't recognise the command kubectl --all-namespaces
or any kind of shortcut to minimize the typing of the whole command.
To list the existing namespaces in a cluster 'kubectl get namespace' command is used. After executing the command, the following output will be generated: Observe that the Kubernetes object starts with four initial namespaces: Default, kube-node-lease, kube-public, and kube-system.
In this exercise you will use kubectl to fetch all of the Pods running in a cluster, and format the output to pull out the list of Containers for each.
The most basic command for viewing Kubernetes objects via kubectl is get . If you run kubectl get <resource-name> you will get a listing of all resources in the current namespace.
New in kubectl v1.14, you can use -A
instead of --all-namespaces
, eg:
kubectl get -A pod
(rejoice)
Is there any alias we can make for all-namespace
Based on this excellent SO answer you can create alias that inserts arguments between prefix and suffix like so:
alias kca='f(){ kubectl "$@" --all-namespaces -o wide; unset -f f; }; f'
and then use it regularly like so:
kca get nodes kca get pods kca get svc,sts,deploy,pvc,pv
etc..
Note: There is -o wide
added for fun as well to get more detailed info about resources not normally namespaced like nodes
and pv
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With