alias kchns='kubectl config set-context --current --namespace' Then use:
The short answer:
However, you can change the namespace in several effective ways: (most common) kubectl get pods -n my-namespace 2. Change default namespace for current context (persistent until changed) kubectl config set-context --current --namespace=my-namespace After this, kubectl get pods will use my-namespace without -n . 3. View current namespace kubectl config view --minify -o jsonpath='{..namespace}' 4. Using kubectl plugin kubens (if installed) # Install kubens (part of kubectx) git clone https://github.com/ahmetb/kubectx /opt/kubectx ln -s /opt/kubectx/kubens /usr/local/bin/kubens Change namespace kubens my-namespace 5. Quick alias for convenience Add to ~/.bashrc or ~/.zshrc : kubectl change namespace