Skip to content

Can not access /metrics endpoint using the IKubernetes.HttpClient. Restults in Unauthorized access. RBAC settings are correct #1556

Closed
@sfahadrizvi

Description

@sfahadrizvi

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions