Search code examples
gokuberneteskubernetes-go-client

How do I get the kubernetes Role or service account where the process is running


I'm using k8s go-client to do a bunch of stuff, but users of the application are seeing errors that seem to be caused by bad configuration of the service account their instance is running with, such as trying to access resources they're not allowed to, I want to show a warning when launching the application, or at least be able to access the permitted resources/groups of the Role bound to the service account of the pod where the code is running. Is there a way to do this?


Solution

  • You can access the the resources available to the pod through its service account by using InClusterConfig. Take a look at the below link to understand how to use it.

    How to use inclusterconfig of kubernetes in go