|
1 | 1 | tests: |
2 | 2 | - script: | |
3 | | - # The following example exercises permissions granted by the monitoring-alertmanager-view Role. |
4 | | - # The binding commands are supposed to run by a user with the necessary privileges. |
| 3 | + ## The following example exercises permissions granted by the `monitoring-alertmanager-view` role. |
| 4 | + ## The binding commands must be run by a user with the necessary privileges. |
| 5 | + # Create a test namespace and a service account. |
5 | 6 | oc create namespace test-alertmanager-web-monitoring-alertmanager-view |
6 | 7 | oc create serviceaccount am-client --namespace=test-alertmanager-web-monitoring-alertmanager-view |
7 | | - # The binding is done to a Service Account, but it can also be applied to any other user. |
| 8 | + # Bind the role to the service account. |
| 9 | + # The binding in this example is applied to a service account but can also be applied to any user. |
8 | 10 | oc create rolebinding test-alertmanager-web-monitoring-alertmanager-view \ |
9 | 11 | --namespace=openshift-monitoring \ |
10 | 12 | --role=monitoring-alertmanager-view \ |
11 | 13 | --serviceaccount=test-alertmanager-web-monitoring-alertmanager-view:am-client |
12 | | - # The token can then be used to access the endpoints. |
| 14 | + # Generate a token to access the endpoints. |
13 | 15 | TOKEN=$(oc create token am-client --namespace=test-alertmanager-web-monitoring-alertmanager-view) |
| 16 | + # Access Alertmanager endpoints externally. |
14 | 17 | ROUTE=$(oc get route alertmanager-main --namespace=openshift-monitoring -ojsonpath={.spec.host}) |
15 | 18 | curl -k -H "Authorization: Bearer $TOKEN" "https://$ROUTE/api/v2/alerts?filter=alertname=Watchdog" |
16 | | - # The endpoints can also be accessed from within the cluster. |
| 19 | + # Access Alertmanager endpoints from within the cluster. |
17 | 20 | curl -k -H "Authorization: Bearer $TOKEN" "https://alertmanager-main.openshift-monitoring:9094/api/v2/alerts?filter=alertname=Watchdog" |
18 | 21 | tearDown: | |
19 | 22 | oc delete rolebinding test-alertmanager-web-monitoring-alertmanager-view --namespace=openshift-monitoring |
20 | 23 | oc delete namespace test-alertmanager-web-monitoring-alertmanager-view --wait=false |
21 | 24 | - script: | |
22 | | - # The following example exercises permissions granted by the monitoring-alertmanager-edit Role. |
23 | | - # The binding commands are supposed to run by a user with the necessary privileges. |
| 25 | + ## The following example exercises permissions granted by the `monitoring-alertmanager-edit` role. |
| 26 | + ## The binding commands must be run by a user with the necessary privileges. |
| 27 | + # Create a test namespace and a service account. |
24 | 28 | oc create namespace test-alertmanager-web-monitoring-alertmanager-edit |
25 | 29 | oc create serviceaccount am-client --namespace=test-alertmanager-web-monitoring-alertmanager-edit |
26 | | - # The binding is done to a Service Account, but it can also be applied to any other user. |
| 30 | + # Bind the role to the service account. |
| 31 | + # The binding in this example is applied to a service account but can also be applied to any user. |
27 | 32 | oc create rolebinding test-alertmanager-web-monitoring-alertmanager-edit \ |
28 | 33 | --namespace=openshift-monitoring \ |
29 | 34 | --role=monitoring-alertmanager-edit \ |
30 | 35 | --serviceaccount=test-alertmanager-web-monitoring-alertmanager-edit:am-client |
31 | | - # The token can then be used to access the endpoints on the port. |
| 36 | + # Generate a token to access the endpoints. |
32 | 37 | TOKEN=$(oc create token am-client --namespace=test-alertmanager-web-monitoring-alertmanager-edit) |
| 38 | + # Access Alertmanager endpoints externally. |
33 | 39 | ROUTE=$(oc get route alertmanager-main --namespace=openshift-monitoring -ojsonpath={.spec.host}) |
34 | 40 | curl -k -X POST "https://$ROUTE/api/v2/silences" \ |
35 | 41 | -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \ |
|
46 | 52 | "createdBy": "test-alertmanager-web-monitoring-alertmanager-edit/am-client", |
47 | 53 | "comment": "Silence test" |
48 | 54 | }' |
49 | | - # The endpoints can also be accessed from within the cluster. |
| 55 | + # Access Alertmanager endpoints from within the cluster. |
50 | 56 | curl -k -X POST "https://alertmanager-main.openshift-monitoring:9094/api/v2/silences" \ |
51 | 57 | -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \ |
52 | 58 | -d '{ |
|
0 commit comments