Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1. Namespace is forbidden: User cannot list resource "namespaces" in API group. #97

Open
marcgarciajr opened this issue Oct 21, 2020 · 10 comments

Comments

@marcgarciajr
Copy link

Any idea why would this happen? Seems like the Go app can't list the namespaces. What can I do in this case?

It is configured for AWS ECR the same registry works fine on minikube, but in dev cluster, it doesn't.

Here is the error:

`time="2020-10-21T05:10:45Z" level=info msg="Starting up..."
time="2020-10-21T05:10:45Z" level=info msg="Using AWS Account: 81xxxxxxxx"
time="2020-10-21T05:10:45Z" level=info msg="Using AWS Region: ca-central-1"
time="2020-10-21T05:10:45Z" level=info msg="Using AWS Assume Role: arn:aws:iam::81xxxxxxx:role/xxxxxxxxxx"
time="2020-10-21T05:10:45Z" level=info msg="Refresh Interval (minutes): 60"
time="2020-10-21T05:10:45Z" level=info msg="Retry Timer: simple"
time="2020-10-21T05:10:45Z" level=info msg="Token Generation Retries: 3"
time="2020-10-21T05:10:45Z" level=info msg="Token Generation Retry Delay (se

ERROR: logging before flag.Parse: E1021 05:11:37.436054 1 reflector.go:199] github.com/upmc-enterprises/registry-creds/vendor/k8s.io/client-go/tools/cache/reflector.go:94: Failed to list *v1.Namespace: namespaces is forbidden: User "system:serviceaccount:kube-system:default" cannot list resource "namespaces" in API group "" at the cluster scope`

It is on an infinite loop outputting the error above.

@marcgarciajr marcgarciajr changed the title Not working on one specific cluster. v1. Namespace is forbidden: User cannot list resource "namespaces" in API group. Oct 21, 2020
@briprowe
Copy link

briprowe commented Nov 10, 2020

I am also intermittently encountering this when running in minikube.

minikube version: v1.14.2
commit: 2c82918e2347188e21c4e44c8056fc80408bce10

@KennyReeldata
Copy link

Running into this with K3s in an on-premise setup as well..

@Keralin
Copy link

Keralin commented Dec 10, 2020

You have to allow the serviceaccount that you are using to list some resources from kubernetes otherwise it will fail like yours it's failing. It is failing because doesnt have the enough permissions to be able to do some actions (in th is case list all the namespaces). You can define new permissions or create anoñther serviceAccount to avoid editing the default one that comes from Kubernetes.

@lackhoa
Copy link

lackhoa commented Dec 21, 2020

What is the permissions that this app need? Do you assume that it should run as admin?

@Keralin
Copy link

Keralin commented Dec 21, 2020

What is the permissions that this app need? Do you assume that it should run as admin?

No that's wrong, you should'nt run as admin. In my case I added the permissions:
namespace: list, get, watch
secrets: get, list, watch, create, update, patch and delete
serviceaccount: all the permissions.

Remember that the app list all namespaces, and updates or creates secrets to that namespace with the secrets to allow that namespace to dowload the images from the private repository

@lackhoa
Copy link

lackhoa commented Dec 21, 2020

@Keralin What do you mean "in your case"? Are there different use cases?
I read that only the default serviceAccount is mutated, so do we really need all the permissions for all serviceAccounts?

@Keralin
Copy link

Keralin commented Jul 20, 2021

@lackhoa Sorry for the delay, I just added to this PR with the files you will need. #103

@ac5tin
Copy link

ac5tin commented Apr 7, 2022

i only configured the secrests.yml and deployment.yml for AWS ECR and got the following error in the pod

 Failed to list *v1.Namespace: namespaces is forbidden: User "system:serviceaccount:kube-system:default" cannot list resource "namespaces" in API group "" at the cluster scope

@kaiffeetasse
Copy link

@ac5tin I think you are missing the api_groups = "" permission

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants