Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upPrometheus cannot discover services, pods, etc. from Kubernetes user namespaces #1951
Comments
sudhi-vm
referenced this issue
Sep 6, 2016
Closed
Add support for user namespaces in Kubernetes discovery #1952
This comment has been minimized.
This comment has been minimized.
|
CC: @fabxc |
This comment has been minimized.
This comment has been minimized.
|
The Prometheus Kubernetes discovery already supports Kubernetes namespaces. By default all namespaces get scraped, this can be changed by using relabeling and the
This is not true, these endpoints are namespace agnostic.
No, we want to be able to scrape all namespaces at once. |
This comment has been minimized.
This comment has been minimized.
|
@grobie I agree that "/api/v1/services" are namespace agnostic. My comment about Consider the use case where the prometheus server is deployed in a user namespace (which is what we are doing) in K8. In this case, the prometheus server has access only to resources in that namespace. With RBAC/ABAC enabled on k8, this would result in a "403 Forbidden" response from k8 API server during discovery. One solution could be to use "/api/v1/namespaces/{{namespace}}/services" if namespace is provided in the config, otherwise use "/api/v1/services". I updated the issue description & commit accordingly. |
This comment has been minimized.
This comment has been minimized.
That also depends on the respective authorization settings I think. We actually deploy our Prometheus server in a custom namespace and gave that special namespace the necessary rights (via a ABAC authorization policy file) to scrape all other namespaces. I'd like to avoid introducing another configuration option if possible. Could you solve your problem by changing your authorization policy? |
This comment has been minimized.
This comment has been minimized.
|
The specific use case is we have our application and prometheus deployed in a custom namespace in Kubernetes. We want the prometheus server to scrape metrics only from our application pods & services running within the custom namespace. Having authorization policy to allow access to other namespaces does not seem right from security point of view. Another option that may avoid extra config param is to automatically read the namespace from |
This comment has been minimized.
This comment has been minimized.
|
While I'm not keen on it personally, I can see the valid use case that we can't cover without a loose auth policy. If we were to do this then I would prefer to support optional multiple namespaces via config, although that increases the number of watches required to be set up (they are cheap I guess). We can retain backwards compatibility easily here too by keeping existing functionality if no namespaces are specified. |
sudhi-vm
added a commit
to sudhi-vm/prometheus
that referenced
this issue
Sep 12, 2016
This comment has been minimized.
This comment has been minimized.
|
Sorry, I overlooked that issue. Seems like the Kubernetes SD will simply not work with auth policies setup, which is not really acceptable. I'm not familiar with the authz behavior. Do we have a way to determine namespaces we have access to so that we could do this automatically behind the scenes? |
brian-brazil
referenced this issue
Oct 27, 2016
Closed
OpenShift Pod Service Discovery for restricted serviceaccount #2127
This comment has been minimized.
This comment has been minimized.
nsams
commented
Oct 27, 2016
|
In OpenShift there is the additional endpoint |
This comment has been minimized.
This comment has been minimized.
|
Implemented in #2642. |
grobie
closed this
May 25, 2017
tedmiston
added a commit
to astronomer/helm.astronomer.io
that referenced
this issue
Jul 23, 2018
This comment has been minimized.
This comment has been minimized.
lock
bot
commented
Mar 23, 2019
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
sudhi-vm commentedSep 6, 2016
•
edited
The current Kubernetes discovery module assumes the services, pods, etc. are always available on "/api/v1/services", "/api/v1/pods", etc. paths. Kubernetes supports having services, pods, etc. hosted in different namespaces. If prometheus server itself is deployed in a pod running within a namespace, then it has access only to resources in that namespace. Trying to access "/api/v1/pods" or "/api/v1/services" without specifying namespace results in "403 Forbidden" from the API server.