Skip to content

Commit

Permalink
use namespaced-role/rolebinding
Browse files Browse the repository at this point in the history
Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
  • Loading branch information
sunjayBhatia committed May 7, 2024
1 parent 23a1bb4 commit af7fbff
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 42 deletions.
38 changes: 0 additions & 38 deletions examples/prometheus/clusterrole-patch.json

This file was deleted.

26 changes: 26 additions & 0 deletions examples/prometheus/rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: prometheus
namespace: projectcontour
rules:
- apiGroups: [""]
resources: ["pods", "services", "endpoints"]
verbs: ["get", "list", "watch"]
- apiGroups: ["networking.k8s.io"]
resources: ["ingresses"]
verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: prometheus
namespace: projectcontour
subjects:
- kind: ServiceAccount
name: prometheus-k8s
namespace: monitoring
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: prometheus
6 changes: 2 additions & 4 deletions site/content/docs/main/guides/prometheus.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,10 @@ $ kubectl apply -f examples/grafana/httpproxy.yaml

### Scrape Contour and Envoy metrics

To enable Prometheus to scrape metrics from the Contour and Envoy pods, some small customizations are needed to the sample deployment:

Update `ClusterRole` to enable the installed Prometheus instance to monitor `Pods` and other resources in all namespaces:
To enable Prometheus to scrape metrics from the Contour and Envoy pods, we can add some RBAC customizations with a `Role` and `RoleBinding` in the `projectcontour` namespace:

```sh
$ kubectl patch clusterrole prometheus-k8s --type=json --patch-file examples/prometheus/clusterrole-patch.json
kubectl apply -f examples/prometheus/rbac.yaml
```

Now add [`PodMonitor`][6] resources for scraping metrics from Contour and Envoy pods in the `projectcontour` namespace:
Expand Down

0 comments on commit af7fbff

Please sign in to comment.