Skip to content

Commit

Permalink
fix(kind): ensure prometheus can discover all services (#272)
Browse files Browse the repository at this point in the history
Previously, prometheus deployed to monitoring namespace wasn't able to
discover kepler deployed to `openshift-kepler-operator` because it
lacked the rbac to discover services outside `monitoring` namespace.
This commit fixes it by adding additional rbac rules allowing all
services to be discovered.

Signed-off-by: Sunil Thaha <sthaha@redhat.com>
  • Loading branch information
sthaha authored Oct 11, 2023
1 parent 9528e2c commit 0440620
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
3 changes: 3 additions & 0 deletions hack/cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ cluster_prereqs() {

info "Ensure openshift namespace for dashboard exists"
run kubectl create namespace openshift-config-managed

info "Ensure prometheus can monitor all namespaces"
run kubectl create -f hack/monitoring/rbac
}

ensure_all_tools() {
Expand Down
25 changes: 25 additions & 0 deletions hack/monitoring/rbac/prometheus-cr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# NOTE: prometheus itself requires these rbac for service discovery
# ref: https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/rbac.md#prometheus-rbac

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: prometheus-discovery
rules:
- apiGroups: [""]
resources:
- nodes
- nodes/metrics
- services
- endpoints
- pods
- configmaps
- secrets
verbs: ["get", "list", "watch"]
- apiGroups:
- networking.k8s.io
resources:
- ingresses
verbs: ["get", "list", "watch"]
- nonResourceURLs: ["/metrics"]
verbs: ["get"]
15 changes: 15 additions & 0 deletions hack/monitoring/rbac/prometheus-k8s-full-crb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# NOTE: prometheus itself requires these rbac for service discovery
# ref: https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/rbac.md#prometheus-rbac

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: prometheus-k8s-full
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: prometheus-discovery
subjects:
- kind: ServiceAccount
name: prometheus-k8s
namespace: monitoring

0 comments on commit 0440620

Please sign in to comment.