Home > Enterprise >  Get Kubernetes pods information through microservice
Get Kubernetes pods information through microservice

Time:01-31

When sending request to api, it throws NPE at api.listPodForAllNamespaces step. Could you please advise, what should be the correct configuration here?

CodePudding user response:

As the error says:

pods is forbidden: User \"system:serviceaccount:sds-test:default\" cannot list resource \"pods\"

This means that the service account default in the namespace sds-test does not have the appropriate permissions to list pods. You are probably not specifying a service account when you deploy. K8s will automatically assign you the default service account.

You need to create a ServiceAccount. Grant it the required access using a Role and RoleBinding. Then update your Deployment/Pod to use your newly created ServiceAccount. Details of which can be found here

  • Related