Is it possible to configure a default namespace (other than "default") for a user in kubernetes?
Thank you.
Yes, just set .contexts[].context.namespace
in the kubeconfig file of the user.
You can do that manually with a text editor (~/.kube/config
):
apiVersion: v1
clusters:
...
contexts:
- context:
cluster: development
namespace: frontend
user: developer
name: dev-frontend
current-context: dev-frontend
kind: Config
preferences: {}
users:
...
Or with kubectl config
. This example sets the namespace to frontend
in the current context:
kubectl config set "contexts."`kubectl config current-context`".namespace" frontend
For more details and explanation see this document.
Set namespace to current-context with:kubectl config set-context --current --namespace=my-namespace
orkubectl config set-context $(kubectl config current-context) --namespace=<namespace>
Check whether it is set or not with:kubectl config view | grep namespace:
ref:kubectl cheatsheet
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With