shortcut for typing kubectl --all-namespaces everytime

9/5/2018

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.

-- Tinkal Gogoi
bash
kubectl
kubernetes
shell

3 Answers

8/18/2019

New in kubectl v1.14, you can use -A instead of --all-namespaces, eg:

kubectl get -A pod

(rejoice)

-- Tracey Jaquith
Source: StackOverflow

9/5/2018

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...

-- Const
Source: StackOverflow

8/18/2019

New in kubectl v1.14, you can use -A instead of --all-namespaces, eg:

kubectl get -A pod

(rejoice)

-- Tracey Jaquith
Source: StackOverflow