Skip to content

Commit b9571a1

Browse files
author
Shubha Narayanan
committed
Added Role and RoleBinding objects
1 parent b8d7c38 commit b9571a1

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

modules/cert-manager-enable-metrics.adoc

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,45 @@ You can enable monitoring and metrics collection for the {cert-manager-operator}
2222
$ oc label namespace cert-manager openshift.io/cluster-monitoring=true
2323
----
2424

25-
. Enable monitoring for user-defined projects. See _Enabling monitoring for user-defined projects_ for instructions.
26-
2725
. Create a service monitor:
2826

29-
.. Create a YAML file that defines the `ServiceMonitor` object:
27+
.. Create a YAML file that defines the `Role`, `RoleBinding`, and `ServiceMonitor` objects:
3028
+
31-
.Example `service-monitor.yaml` file
29+
.Example `monitoring.yaml` file
30+
3231
[source,yaml]
3332
----
33+
apiVersion: rbac.authorization.k8s.io/v1
34+
kind: Role
35+
metadata:
36+
name: prometheus-k8s
37+
namespace: cert-manager
38+
rules:
39+
- apiGroups:
40+
- ""
41+
resources:
42+
- services
43+
- endpoints
44+
- pods
45+
verbs:
46+
- get
47+
- list
48+
- watch
49+
---
50+
apiVersion: rbac.authorization.k8s.io/v1
51+
kind: RoleBinding
52+
metadata:
53+
name: prometheus-k8s
54+
namespace: cert-manager
55+
roleRef:
56+
apiGroup: rbac.authorization.k8s.io
57+
kind: Role
58+
name: prometheus-k8s
59+
subjects:
60+
- kind: ServiceAccount
61+
name: prometheus-k8s
62+
namespace: openshift-monitoring
63+
---
3464
apiVersion: monitoring.coreos.com/v1
3565
kind: ServiceMonitor
3666
metadata:
@@ -53,9 +83,9 @@ spec:
5383
app.kubernetes.io/name: cert-manager
5484
----
5585

56-
.. Create the `ServiceMonitor` object by running the following command:
86+
.. Create the `Role`, `RoleBinding`, and `ServiceMonitor` objects by running the following command:
5787
+
5888
[source,terminal]
5989
----
60-
$ oc create -f service-monitor.yaml
90+
$ oc create -f monitoring.yaml
6191
----

security/cert_manager_operator/cert-manager-monitoring.adoc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ include::modules/cert-manager-enable-metrics.adoc[leveloffset=+1]
1414
[role="_additional-resources"]
1515
.Additional resources
1616

17-
* xref:../../monitoring/enabling-monitoring-for-user-defined-projects.adoc#enabling-monitoring-for-user-defined-projects_enabling-monitoring-for-user-defined-projects[Enabling monitoring for user-defined projects]
1817
* xref:../../monitoring/managing-metrics.adoc#setting-up-metrics-collection-for-user-defined-projects_managing-metrics[Setting up metrics collection for user-defined projects]
1918
2019
// Querying metrics for the {cert-manager-operator}

0 commit comments

Comments
 (0)