# Get all namespaces from rancher-cli

**URL:** <https://forums.suse.com/t/get-all-namespaces-from-rancher-cli/37270>\
**Category:** SUSE Rancher Prime\
**Created:** [March 15, 2022, 12:39pm UTC](https://forums.suse.com/t/get-all-namespaces-from-rancher-cli/37270 "2022-03-15T12:39:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mortenb123](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/mortenb123/32/8084_2.png) [@mortenb123](https://forums.suse.com/u/mortenb123)\
**Post date:** [March 15, 2022, 12:39pm UTC](https://forums.suse.com/t/get-all-namespaces-from-rancher-cli/37270/1 "2022-03-15T12:39:03Z")

</div>

Is there a way to get a list of all namespaces on cluster like we get in the webgui?.  
I can list anything as long as I specify the namespace, can I use an rest-api?

```auto
rancher.exe kubectl get namespace
Error from server (Forbidden): namespaces is forbidden: User "u-vk5xagyeva" cannot list resource "namespaces" in API group "" at the cluster scope
exit status 1

rancher.exe kubectl get pods --namespace=id-pro-hso-hso-scim-api-test12
NAME READY STATUS RESTARTS AGE
id-pro-hso-hso-scim-api-test12-846f7bf8bc-fbqbs 1/1 Running 2 13d
id-pro-hso-hso-scim-api-test12-846f7bf8bc-sp79b 1/1 Running 3 13d

```

---

<div class="post-metadata">

**Author:** ![wcoateRR](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/wcoaterr/32/8144_2.png) [@wcoateRR](https://forums.suse.com/u/wcoateRR)\
**Post date:** [March 15, 2022, 2:00pm UTC](https://forums.suse.com/t/get-all-namespaces-from-rancher-cli/37270/2 "2022-03-15T14:00:51Z")

</div>

I don’t use the Rancher CLI, but normal kubectl works fine to get a list of namespaces with `kubectl get namespaces`. Are you sure the user referenced has permission for the specific cluster you’re pointed at? You can see the user & server you’re pointed at in your ~/.kube/config normally.

---

<div class="post-metadata">

**Author:** ![mortenb123](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/mortenb123/32/8084_2.png) [@mortenb123](https://forums.suse.com/u/mortenb123)\
**Post date:** [March 16, 2022, 9:26am UTC](https://forums.suse.com/t/get-all-namespaces-from-rancher-cli/37270/3 "2022-03-16T09:26:06Z")

</div>

Hi  
Found it: `rancher-cli namespaces ls --all-namespaces`  
I do not have any kubectl config, only a .rancher\cli2.json that points to the various clusters

Thanks
