# K8s endpoint authorization

**URL:** <https://forums.suse.com/t/k8s-endpoint-authorization/14178>\
**Category:** SUSE Rancher Prime\
**Created:** [May 6, 2019, 3:00pm UTC](https://forums.suse.com/t/k8s-endpoint-authorization/14178 "2019-05-06T15:00:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sergey](https://avatars.discourse-cdn.com/v4/letter/s/9fc348/32.png) [@sergey](https://forums.suse.com/u/sergey)\
**Post date:** [May 6, 2019, 3:00pm UTC](https://forums.suse.com/t/k8s-endpoint-authorization/14178/1 "2019-05-06T15:00:57Z")

</div>

Hello.

I attempt to setup cluster monitoring with Prometheus. I want it to be an external to the cluster, so i going not to use build-in prometheus deployment of Rancher v2.2.2.

I have created Bearer token for user in Rancher, and using it i succesfully scraped metrics about nodes and points. But i cannot get metrics of endpoints.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/suse/original/2X/d/d3427edb9a96d06d0cfc839b8a45683154c0cd49.png)

Here is part of my prometheus.yml:

```
# =========================================
# metrics for default/kubernetes api's from the kubernetes master
# =========================================
- job_name: 'kubernetes-apiservers'
  kubernetes_sd_configs:
  - role: endpoints
    api_server: https://192.168.100.15/k8s/clusters/c-lhfkr
    tls_config:
      insecure_skip_verify: true
    bearer_token: "token-8mtmm:qbnzv2z4rxwwbtmns787lqrt6f6qqlnw5kghv9qppvht4jzz27fqvb"
  scheme: https
  tls_config:
    insecure_skip_verify: true
  bearer_token: "token-8mtmm:qbnzv2z4rxwwbtmns787lqrt6f6qqlnw5kghv9qppvht4jzz27fqvb"
  relabel_configs:
  - source_labels: [__meta_kubernetes_namespace,__ meta_kubernetes_service_name, __meta_kubernetes_endpoint_port_name]
    action: keep
    regex: default;kubernetes;https

```

So it succesfully scraped service discovery info, but then Prometheus try to scrape metrics of kube-apiserver failed with 401 Unauthorized.

I think, it is because request to “[https://192.168.100.11:6443/metrics](https://192.168.100.11:6443/metrics)” bypassing Rancher auth proxy. I can manually create service account and generate token for it in k8s, and it works. But i want to use token from Rancher…

How can i solve it?

---

<div class="post-metadata">

**Author:** ![sergey](https://avatars.discourse-cdn.com/v4/letter/s/9fc348/32.png) [@sergey](https://forums.suse.com/u/sergey)\
**Post date:** [May 8, 2019, 11:34am UTC](https://forums.suse.com/t/k8s-endpoint-authorization/14178/2 "2019-05-08T11:34:21Z")

</div>

Okay.

There is a [http://rancher/k8s/cluster/c-lhfkr/metrics](http://rancher/k8s/cluster/c-lhfkr/metrics) link. What does this metrics for? I believe, it is for API endpoint, but which one?
