34

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?

2 Answers2

34
$ kubectl get ns
$ kubectl describe ns

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

 $ kubens
Rob Bednark
  • 25,981
  • 23
  • 80
  • 125
Rico
  • 58,485
  • 12
  • 111
  • 141
10

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

kevingessner
  • 18,559
  • 5
  • 43
  • 63
  • Why do I keep getting `Unable to connect to the server: dial tcp: lookup something.eks.amazonaws.com on 10.10.0.2:53: no such host` . Thanks – mdabdullah Apr 08 '21 at 19:36
  • use this command: az aks command invoke -g -n -c "kubectl get namespaces" @mdabdullah – Utsav Dawn Jun 30 '22 at 17:14