<p>I'm new to k8s, prometheus. I'm trying to collect the metrics of each pods with prometheus but unable to so because of the error:
<a href="https://i.stack.imgur.com/QZajf.png" rel="nofollow noreferrer">API ERROR</a>.</p>

<pre><code>{
  "kind": "Status",
  "apiVersion": "v1",
  "metadata": {

  },
  "status": "Failure",
  "message": "forbidden: User \"system:anonymous\" cannot get path \"/metrics\"",
  "reason": "Forbidden",
  "details": {

  },
  "code": 403
}
</code></pre>

<p><code>system:anonymous</code> means that an unauthenticated user is trying to get a resource from your cluster, which is forbidden. You will need to create a service account, then give that service account some permissions through RBAC, then make that service account to get the metrics. All that is documented.</p>

<p>As a workaround, you can do this:</p>

<pre><code>kubectl create clusterrolebinding prometheus-admin --clusterrole cluster-admin --user system:anonymous
</code></pre>

<p>Now, note that this is a <strong>terrible</strong> idea, unless you are playing with kubernetes. With this permission you are giving any unauthenticated user total permissions into your cluster.</p>
