kubectl-tree icon indicating copy to clipboard operation
kubectl-tree copied to clipboard

Cannot run with viewer role

Open tjun opened this issue 5 years ago • 4 comments

In querying APIs, failed to list secret and cannot show the result.

When I try to run kubectl tree with viewer role, got the following error:

Error: error while querying api objects: listing resources failed (/v1, Resource=secrets): 
secrets is forbidden: User "[email protected]" cannot list resource "secrets" in API group "" at the cluster scope: Required "container.secrets.list" permission.

tjun avatar Jan 03 '20 14:01 tjun

Hi @tjun! I believe this could be solved by just updating your role to have list permissions on Secret objects. Do you have permissions in you cluster to modify RBAC?

hasheddan avatar Jan 03 '20 16:01 hasheddan

I think we’re talking about GKE Viewer role here. Have you tried “viewer” role in Kubernetes rbac?

I suspect GKE Viewer doesn’t let the subject to view Secrets in a cluster, for a good reason.

ahmetb avatar Jan 03 '20 16:01 ahmetb

Thanks!

Have you tried “viewer” role in Kubernetes rbac?

Yes, I already have a viewer role in Kubernetes rbac for the target namespace. Doesn't have cluster level viewer role. I think kubectl-tree try to fetch Secrets on other namespace(default)?

tjun avatar Jan 04 '20 09:01 tjun

Kubectl tree tries to retrieve every single API resource in your cluster.

In the future we might introduce an --ignore-inaccessible option (and log those failures as warnings), but for now we flat out fail.

ahmetb avatar Jan 05 '20 21:01 ahmetb