Switch namespaces in Kubernetes
1. Set a Default Namespace for Your Context
kubectl config set-context --current --namespace=<namespace>Example:
kubectl config set-context --current --namespace=devThis sets the default namespace for all kubectl commands in the current context.
2. Use -n or --namespace in Commands
If you don't want to change the default namespace, you can specify it in each command:
kubectl get pods -n <namespace>Example:
kubectl get pods -n dev3. Verify the Active Namespace
To check which namespace is currently set as default:
kubectl config view --minify | grep namespace