How to list all namespaces in a cluster?

8/28/2019

I am trying to figure out how to list all namespaces in a cluster: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/

something like:

kubectl describe cluster --namepaces -o json

anyone know how to list all the namespaces in a K8S/EKS cluster?

--
aws-eks
eks
kubernetes

2 Answers

8/28/2019

Namespaces are an object like any other, so kubectl get namespaces will list them. kubectl describe namespaces will print full details.

-- kevingessner
Source: StackOverflow

8/28/2019

Additionally, (to the other answer), this is a short way:

$ kubectl get ns
$ kubectl describe ns

Also, you can use kubens to list and switch namespaces (on your local KUBECONFIG)

 $ kubens
-- Rico
Source: StackOverflow