Search code examples
kuberneteskubectlkubernetes-security

Kubectl - List only namespaces a user can access


Looking if the below scenario is possible or not -

Lets say user(user1) have access only to namespaces default and marketing.

When we perform kubectl get ns it should display both namespaces.

No other namespaces should be displayed even if they exists because the user1 does not have access to any other namespaces.

We could relate this scenario with the databases where a user can see only the databases they have access to when show databases is performed


Solution

  • This isn't possible in Kubernetes. Namespaces are the resources providing the scoping mechanism to limit visibility into other resources. There's no meta-namespace that provides scoping rules for namespaces.