Description
Describe the bug
I am trying to access the /metrics endpoint from a service running inside a pod. I could not find any API to access the /metrics endpoint so I am using the HttpClient from the Kubernetes object. The Kubernetes object is initialized correctly.
When I try to access the /metrics endpoint using
client.SendAsync(new HttpRequestMessage(HttpMethod.Get, endpoint), ct)
I get a 401. Inspecting the headers of the request I see that it has no token.
If I manually create a token from kubectl and hardcode that token in the Header Authorization: Bearer ...
the service works fine until the token expires. Which shows the RBAC is setup correctly
Is there a way to get the token from the Kubernetes controller. I could not find any documentation to use the API to create a new token at runtime