Kubectl: Get Current, List All – Namepaces in Kubernetes

Kubernetes supports multiple virtual clusters backed by the same physical cluster.

These virtual clusters in Kubernetes are called Namespaces.

The Namespaces allow to partition physical resources into the logically named groups, allowing a Kubernetes cluster to share resources between multiple groups.

In this note i will show how get the current Namespace and how to list all Namespaces in Kubernetes cluster using the kubectl command.

Cool Tip: List Nodes in Kubernetes cluster! Read more →

Get Namespaces in Kubernetes

Get the current Namespace in Kubernetes:

$ kubectl config view --minify --output 'jsonpath={..namespace}'

List all Namespaces in Kubernetes:

$ kubectl get namespaces

– or –

$ kubectl get ns
Was it useful? Share this post with the world!

Leave a Reply