How to know which namespace I am using?

I can use kubectl get namespaces to list all the namespaces:

$ kubectl get namespaces
NAME              STATUS   AGE
default           Active   10d
kube-node-lease   Active   10d
kube-public       Active   10d
kube-system       Active   10d

how to know which namespace I am using?

1 Like

The Kubens/kubectx tool is a great way to see that kind of information quickly and easily.

If you’re just using kubectl you can run kubectl config get-context to show your current cluster context and the last column will be the namespace. Here’s a nice cheat sheet for how to use kubectl and context.

Another handy tool for showing namespaces is kube-ps1 which adds it to your shell env.

Just to clarify the correct command is kubectl config get-contexts

1 Like