We use cookies to make your experience better. By remaining on this website you indicate your consent. Learn more.
kubectl config get-contexts Now the NAMESPACE column should show my-namespace . kubectl get pods This will list pods only in my-namespace , not all namespaces. Important notes | Feature | Behavior | |---------|----------| | Works on | Current context only | | Persistent | Yes — saved in kubeconfig | | Overwrites | Existing namespace in current context | | No effect on | Existing resources, deployments, services | Examples Set namespace for current context:
❌ → In older versions (<1.19), you needed --current . Modern versions assume --current by default. kubectl set namespace
kubectl set namespace ""
Namespace set to "my-namespace". kubectl config view --minify | grep namespace or kubectl config get-contexts Now the NAMESPACE column should