Skip to content

Commit 54b00a8

Browse files
committed
tweak asciiDocs formatting to ease the mapping into the monitoring Docs
Hide the auto examples from asciiDocs as it's still WIP, to avoid confusion
1 parent 0e4f052 commit 54b00a8

File tree

3 files changed

+46
-53
lines changed

3 files changed

+46
-53
lines changed

Documentation/resources.adoc

Lines changed: 9 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,9 @@
44
// make edits or learn more about how this file is generated, read the docgen utility
55
// instructions in the source code for the CMO.
66
:_mod-docs-content-type: REFERENCE
7-
[id="resources-reference-for-the-cluster-monitoring-operator"]
7+
[id="resources-reference-for-the-cluster-monitoring-operator_{context}"]
88
= Resources reference for the Cluster Monitoring Operator
9-
include::_attributes/common-attributes.adoc[]
10-
:context: resources-reference-for-the-cluster-monitoring-operator
119

12-
toc::[]
13-
14-
[id="Cluster-monitoring-resources-reference"]
15-
== Cluster monitoring resources reference
1610
This document describes the following resources deployed and managed by the Cluster Monitoring Operator (CMO):
1711

1812
* link:#cmo-routes-resources[Routes]
@@ -66,57 +60,23 @@ Expose the admission webhook service which validates `PrometheusRules` and `Aler
6660
=== openshift-user-workload-monitoring/alertmanager-user-workload
6761

6862
Expose the user-defined Alertmanager web server within the cluster on the following ports:
63+
6964
* Port 9095 provides access to the Alertmanager endpoints. Granting access requires binding a user to the `monitoring-alertmanager-api-reader` role (for read-only operations) or `monitoring-alertmanager-api-writer` role in the `openshift-user-workload-monitoring` project.
7065
* Port 9092 provides access to the Alertmanager endpoints restricted to a given project. Granting access requires binding a user to the `monitoring-rules-edit` cluster role or `monitoring-edit` cluster role in the project.
7166
* Port 9097 provides access to the `/metrics` endpoint only. This port is for internal use, and no other usage is guaranteed.
7267

7368
=== openshift-monitoring/alertmanager-main
7469

7570
Expose the Alertmanager web server within the cluster on the following ports:
76-
* Port 9094 provides access to all the Alertmanager endpoints. Granting access requires binding a user to the `monitoring-alertmanager-view` role (for read-only operations) or `monitoring-alertmanager-edit` role in the `openshift-monitoring` project.
77-
----
78-
# monitoring-alertmanager-view grants read permissions.
79-
$ oc project openshift-monitoring
80-
$ oc create serviceaccount am-ro-client
81-
$ oc adm policy add-role-to-user monitoring-alertmanager-view \
82-
--role-namespace=openshift-monitoring --rolebinding-name=am-ro-client \
83-
--serviceaccount=am-ro-client
84-
$ TOKEN=$(oc create token am-ro-client)
85-
$ ROUTE=$(oc get route alertmanager-main -n openshift-monitoring -ojsonpath={.spec.host})
86-
$ curl -H "Authorization: Bearer $TOKEN" -k --fail-with-body "https://$ROUTE/api/v2/alerts?filter=alertname=Watchdog"
87-
----
88-
----
89-
# monitoring-alertmanager-edit grants edit permissions.
90-
$ oc project openshift-monitoring
91-
$ oc create serviceaccount am-rw-client
92-
$ oc adm policy add-role-to-user monitoring-alertmanager-edit \
93-
--role-namespace=openshift-monitoring --rolebinding-name=am-rw-client \
94-
--serviceaccount=am-rw-client
95-
$ TOKEN=$(oc create token am-rw-client)
96-
$ ROUTE=$(oc get route alertmanager-main -n openshift-monitoring -ojsonpath={.spec.host})
97-
$ curl -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
98-
-d '{
99-
"matchers": [
100-
{
101-
"name": "alertname",
102-
"value": "MyTestAlert",
103-
"isRegex": false
104-
}
105-
],
106-
"startsAt": "2044-01-01T00:00:00Z",
107-
"endsAt": "2044-01-01T00:00:01Z",
108-
"createdBy": "am-rw-client",
109-
"comment": "Silence test"
110-
}' \
111-
-k --fail-with-body "https://$ROUTE/api/v2/silences"
112-
----
11371

72+
* Port 9094 provides access to all the Alertmanager endpoints. Granting access requires binding a user to the `monitoring-alertmanager-view` role (for read-only operations) or `monitoring-alertmanager-edit` role in the `openshift-monitoring` project.
11473
* Port 9092 provides access to the Alertmanager endpoints restricted to a given project. Granting access requires binding a user to the `monitoring-rules-edit` cluster role or `monitoring-edit` cluster role in the project.
11574
* Port 9097 provides access to the `/metrics` endpoint only. This port is for internal use, and no other usage is guaranteed.
11675

11776
=== openshift-monitoring/kube-state-metrics
11877

11978
Expose kube-state-metrics `/metrics` endpoints within the cluster on the following ports:
79+
12080
* Port 8443 provides access to the Kubernetes resource metrics. This port is for internal use, and no other usage is guaranteed.
12181
* Port 9443 provides access to the internal kube-state-metrics metrics. This port is for internal use, and no other usage is guaranteed.
12282

@@ -135,12 +95,14 @@ Expose the `/metrics` endpoint on port 9100. This port is for internal use, and
13595
=== openshift-monitoring/openshift-state-metrics
13696

13797
Expose openshift-state-metrics `/metrics` endpoints within the cluster on the following ports:
98+
13899
* Port 8443 provides access to the OpenShift resource metrics. This port is for internal use, and no other usage is guaranteed.
139100
* Port 9443 provides access to the internal `openshift-state-metrics` metrics. This port is for internal use, and no other usage is guaranteed.
140101

141102
=== openshift-monitoring/prometheus-k8s
142103

143104
Expose the Prometheus web server within the cluster on the following ports:
105+
144106
* Port 9091 provides access to all the Prometheus endpoints. Granting access requires binding a user to the `cluster-monitoring-view` cluster role.
145107
* Port 9092 provides access to the `/metrics` and `/federate` endpoints only. This port is for internal use, and no other usage is guaranteed.
146108

@@ -155,6 +117,7 @@ Expose the `/metrics` endpoint on port 8443. This port is for internal use, and
155117
=== openshift-user-workload-monitoring/prometheus-user-workload
156118

157119
Expose the Prometheus web server within the cluster on the following ports:
120+
158121
* Port 9091 provides access to the `/metrics` endpoint only. This port is for internal use, and no other usage is guaranteed.
159122
* Port 9092 provides access to the `/federate` endpoint only. Granting access requires binding a user to the `cluster-monitoring-view` cluster role.
160123

@@ -167,6 +130,7 @@ Expose the `/metrics` endpoint on port 8443. This port is for internal use, and
167130
=== openshift-monitoring/thanos-querier
168131

169132
Expose the Thanos Querier web server within the cluster on the following ports:
133+
170134
* Port 9091 provides access to all the Thanos Querier endpoints. Granting access requires binding a user to the `cluster-monitoring-view` cluster role.
171135
* Port 9092 provides access to the `/api/v1/query`, `/api/v1/query_range/`, `/api/v1/labels`, `/api/v1/label/*/values`, and `/api/v1/series` endpoints restricted to a given project. Granting access requires binding a user to the `view` cluster role in the project.
172136
* Port 9093 provides access to the `/api/v1/alerts`, and `/api/v1/rules` endpoints restricted to a given project. Granting access requires binding a user to the `monitoring-rules-edit` cluster role or `monitoring-edit` cluster role or `monitoring-rules-view` cluster role in the project.
@@ -175,6 +139,7 @@ Expose the Thanos Querier web server within the cluster on the following ports:
175139
=== openshift-user-workload-monitoring/thanos-ruler
176140

177141
Expose the Thanos Ruler web server within the cluster on the following ports:
142+
178143
* Port 9091 provides access to all Thanos Ruler endpoints. Granting access requires binding a user to the `cluster-monitoring-view` cluster role.
179144
* Port 9092 provides access to the `/metrics` endpoint only. This port is for internal use, and no other usage is guaranteed.
180145

hack/docgen/managed_resources.go

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,9 @@ To avoid these issues, follow these recommendations:
5959
// make edits or learn more about how this file is generated, read the docgen utility
6060
// instructions in the source code for the CMO.
6161
:_mod-docs-content-type: REFERENCE
62-
[id="resources-reference-for-the-cluster-monitoring-operator"]
62+
[id="resources-reference-for-the-cluster-monitoring-operator_{context}"]
6363
= Resources reference for the Cluster Monitoring Operator
64-
include::_attributes/common-attributes.adoc[]
65-
:context: resources-reference-for-the-cluster-monitoring-operator
6664
67-
toc::[]
68-
69-
[id="Cluster-monitoring-resources-reference"]
70-
== Cluster monitoring resources reference
7165
This document describes the following resources deployed and managed by the Cluster Monitoring Operator (CMO):
7266
7367
* link:#cmo-routes-resources[Routes]
@@ -168,6 +162,11 @@ func PrintManagedResources(format string) error {
168162
return err
169163
}
170164

165+
desc, err = formatDescription(desc, format)
166+
if err != nil {
167+
return err
168+
}
169+
171170
resourcesByKind[o.GetKind()] = append(
172171
resourcesByKind[o.GetKind()],
173172
resource{
@@ -249,7 +248,34 @@ func substitutePlaceholdersInDescription(desc, format string) (string, error) {
249248
} else {
250249
content = suite.StringMarkdown()
251250
}
252-
lines = append(lines, content)
251+
// TODO: remove once unnecessary
252+
if content != "" {
253+
lines = append(lines, content)
254+
}
255+
}
256+
if err := scanner.Err(); err != nil {
257+
return "", err
258+
}
259+
return strings.Join(lines, "\n"), nil
260+
}
261+
262+
// formatDescription improves the formatting of the description according to the desired format.
263+
// For example, for better list rendering.
264+
func formatDescription(desc, format string) (string, error) {
265+
if format != asciiDocsFormat {
266+
return desc, nil
267+
}
268+
269+
var lines []string
270+
scanner := bufio.NewScanner(strings.NewReader(desc))
271+
for scanner.Scan() {
272+
line := scanner.Text()
273+
lines = append(lines, line)
274+
// Supposing a list will exist after "foo bar:"
275+
// make sure to add a new line for better rendering.
276+
if strings.HasSuffix(line, ":") {
277+
lines = append(lines, "")
278+
}
253279
}
254280
if err := scanner.Err(); err != nil {
255281
return "", err

test/e2e/test_command/test_command.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ func (suite *Suite) StringMarkdown() string {
105105
}
106106

107107
func (suite *Suite) StringAscii() string {
108-
return suite.intoCodeBlocks("----")
108+
// Not ready to be part of the doc yet.
109+
return ""
110+
// return suite.intoCodeBlocks("----")
109111
}
110112

111113
func (stc *SetUpTearDownCommand) Run(t *testing.T, wDir, kubeConfigPath string) error {

0 commit comments

Comments
 (0)