Kubernetes & kubectl Cheat Sheet/Set default namespace for context

Persist a default namespace for the current context.

Section: Setup, Contexts, and Cluster Info

Set default namespace for context

bash
bash
kubectl config set-context --current --namespace=payments
Explanation

Persist a default namespace for the current context.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Setup, Contexts, and Cluster Info
View kubeconfig
Inspect the merged kubeconfig content.
OpenIn sheetbashsame section
Show current context
Print the active kubeconfig context.
OpenIn sheetbashsame section
List contexts
List configured contexts and their clusters/users.
OpenIn sheetbashsame section
Switch context
Change the active context in kubeconfig.
OpenIn sheetbashsame section
Show kubectl version
Check the installed kubectl client version.
OpenIn sheetbashsame section
Show client and server version
Print the kubectl client and Kubernetes API server versions.
OpenIn sheetbashsame section