Skip to content

Commit 60ea03f

Browse files
authored
Merge pull request #11286 from mburke5678/enterprise-3.11
[enterprise-3.11] Clearly Specify Router Metrics file format returned
2 parents f93c74d + a4cd362 commit 60ea03f

File tree

1 file changed

+66
-74
lines changed

1 file changed

+66
-74
lines changed

install_config/router/default_haproxy_router.adoc

Lines changed: 66 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,6 @@ The following example creates a router deployment with `0` replicas and
360360
customizes the router service HTTP and HTTPS ports, then scales it
361361
appropriately (to `1` replica).
362362

363-
====
364363
----
365364
$ oc adm router --replicas=0 --ports='10080:10080,10443:10443' //<1>
366365
$ oc set env dc/router ROUTER_SERVICE_HTTP_PORT=10080 \
@@ -369,7 +368,6 @@ $ oc scale dc/router --replicas=1
369368
----
370369
<1> Ensures exposed ports are appropriately set for routers that use the
371370
container networking mode `--host-network=false`.
372-
====
373371

374372
[IMPORTANT]
375373
====
@@ -382,13 +380,10 @@ that you use via `firewall-cmd`).
382380
The following is an example using `iptables` to open the custom router service
383381
ports.
384382

385-
====
386383
----
387384
$ iptables -A INPUT -p tcp --dport 10080 -j ACCEPT
388385
$ iptables -A INPUT -p tcp --dport 10443 -j ACCEPT
389386
----
390-
====
391-
392387
[[working-with-multiple-routers]]
393388
== Working With Multiple Routers
394389

@@ -430,7 +425,6 @@ $ oc edit dc <deploymentConfigName>
430425
Add the `template.spec.nodeSelector` field with a key and value
431426
corresponding to the label:
432427
+
433-
====
434428
----
435429
...
436430
template:
@@ -445,7 +439,6 @@ corresponding to the label:
445439
----
446440
<1> The key and value are `router` and `first`, respectively,
447441
corresponding to the `router=first` label.
448-
====
449442

450443
[[using-router-shards]]
451444
== Using Router Shards
@@ -489,7 +482,6 @@ Separate DNS entries must resolve *.foo.com to the node hosting Router A and *.e
489482
* `*.foo.com A IN 192.168.0.5`
490483
* `*.example.com A IN 192.168.1.9`
491484

492-
493485
*Router Sharding Examples*
494486

495487
This section describes router sharding using namespace and route labels.
@@ -652,7 +644,6 @@ Here is a convenience script *_mkshard_* that
652644
illustrates how `oc adm router`, `oc set env`, and `oc scale`
653645
can be used together to make a router shard.
654646

655-
====
656647
[source,bash]
657648
----
658649
#!/bin/bash
@@ -672,7 +663,6 @@ oc scale $dc --replicas=3 //<5>
672663
The selection expression is the value of
673664
the `ROUTE_LABELS` environment variable.
674665
<5> Scale it up.
675-
====
676666

677667
Running *_mkshard_* several times creates several routers:
678668

@@ -711,7 +701,6 @@ demonstrating how to change the selection expression.
711701
Here is a convenience script *_modshard_* that modifies
712702
an existing router to use a new selection expression:
713703

714-
====
715704
[source,bash]
716705
----
717706
#!/bin/bash
@@ -734,7 +723,6 @@ oc scale $dc --replicas=3 //<5>
734723
non-`ID` arguments to `modshard` must include the
735724
environment variable name as well as its value.
736725
<5> Scale it back up.
737-
====
738726

739727
[NOTE]
740728
====
@@ -874,12 +862,10 @@ this default routing subdomain.
874862
The following example shows how you can set the configured suffix
875863
to *v3.openshift.test*:
876864

877-
====
878865
----
879866
routingConfig:
880867
subdomain: v3.openshift.test
881868
----
882-
====
883869

884870
[NOTE]
885871
====
@@ -891,11 +877,9 @@ xref:../../architecture/networking/routes.adoc#route-hostnames[generated host
891877
name] for the example of a route named *no-route-hostname* without a
892878
host name added to a namespace *mynamespace* would be:
893879

894-
====
895880
----
896881
no-route-hostname-mynamespace.v3.openshift.test
897882
----
898-
====
899883

900884
[[forcing-route-hostnames-to-a-custom-routing-subdomain]]
901885
== Forcing Route Host Names to a Custom Routing Subdomain
@@ -908,11 +892,9 @@ a route and generate one based on the template provided to the
908892
The following example runs a router, which overrides the route host names using
909893
a custom subdomain template `${name}-${namespace}.apps.example.com`.
910894

911-
====
912895
----
913896
$ oc adm router --force-subdomain='${name}-${namespace}.apps.example.com'
914897
----
915-
====
916898

917899
[[using-wildcard-certificates]]
918900
== Using Wildcard Certificates
@@ -922,15 +904,13 @@ default certificate instead. In most cases, this certificate should be provided
922904
by a trusted certificate authority, but for convenience you can use the
923905
{product-title} CA to create the certificate. For example:
924906

925-
====
926907
----
927908
$ CA=/etc/origin/master
928909
$ oc adm ca create-server-cert --signer-cert=$CA/ca.crt \
929910
--signer-key=$CA/ca.key --signer-serial=$CA/ca.serial.txt \
930911
--hostnames='*.cloudapps.example.com' \
931912
--cert=cloudapps.crt --key=cloudapps.key
932913
----
933-
====
934914

935915
[NOTE]
936916
====
@@ -945,19 +925,15 @@ by default *_/etc/ansible/hosts_*.
945925
The router expects the certificate and key to be in PEM format in a single
946926
file:
947927

948-
====
949928
----
950929
$ cat cloudapps.crt cloudapps.key $CA/ca.crt > cloudapps.router.pem
951930
----
952-
====
953931

954932
From there you can use the `--default-cert` flag:
955933

956-
====
957934
----
958935
$ oc adm router --default-cert=cloudapps.router.pem --service-account=router
959936
----
960-
====
961937

962938
[NOTE]
963939
====
@@ -1108,7 +1084,6 @@ DNS lookup:
11081084
# curl -k --resolve www.example.test:443:$routerip https://www.example.test/
11091085
----
11101086

1111-
11121087
[[using-wildcard-routes]]
11131088
== Using Wildcard Routes (for a Subdomain)
11141089

@@ -1450,18 +1425,14 @@ stack, use the `--host-network=false` option when creating the router. For
14501425
example:
14511426

14521427
ifdef::openshift-enterprise[]
1453-
====
14541428
----
14551429
$ oc adm router --service-account=router --host-network=false
14561430
----
1457-
====
14581431
endif::[]
14591432
ifdef::openshift-origin[]
1460-
====
14611433
----
14621434
$ oc adm router --service-account=router --host-network=false
14631435
----
1464-
====
14651436
endif::[]
14661437

14671438
Internally, this means the router container must publish the 80 and 443
@@ -1486,7 +1457,6 @@ access any pod in the cluster. If isolation is needed in this case, then do not
14861457
add routes across the namespaces.
14871458
====
14881459

1489-
14901460
[[exposing-the-router-metrics]]
14911461
== Exposing Router Metrics
14921462

@@ -1495,63 +1465,49 @@ xref:../../architecture/networking/assembly_available_router_plugins.adoc#haprox
14951465
are, by default, exposed or published in
14961466
link:https://prometheus.io/docs/concepts/data_model/[Prometheus format]
14971467
for consumption by external metrics collection and aggregation systems (e.g. Prometheus, statsd).
1498-
Metrics are also available dirctly from the
1499-
link:https://cbonte.github.io/haproxy-dconv/1.5/configuration.html#9[HAProxy router] in its own CSV format.
1468+
Metrics are also available directly from the
1469+
link:https://cbonte.github.io/haproxy-dconv/1.5/configuration.html#9[HAProxy router] in its own HTML format for viewing in a browser
1470+
or CSV download.
1471+
These metrics include the HAProxy native metrics and some controller metrics.
1472+
1473+
When you create a router using the following command, {product-title} makes metrics available in Prometheus format on the stats port, by default 1936.
15001474

1501-
When you create a router, as below,
1502-
====
15031475
----
15041476
$ oc adm router --service-account=router
15051477
----
1506-
====
1507-
metrics are automatically available in Prometheus format on the stats-port, default 1936. To suppress metrics collection,
1508-
====
1478+
1479+
* To extract the raw statistics in Prometheus format run the following command:
1480+
+
15091481
----
1510-
$ oc adm router --service-account=router --stats-port=0
1482+
curl <user>:<password>@<router_IP>:<STATS_PORT>
15111483
----
1512-
====
1513-
1514-
To switch to the HAProxy CSV format metrics, edit the xref:../../architecture/networking/routes.adoc#env-variables[environment variables]
1515-
for the router dc and delete the following lines:
1516-
1517-
====
1484+
+
1485+
For example:
1486+
+
15181487
----
1519-
- name: ROUTER_LISTEN_ADDR
1520-
value: 0.0.0.0:1936
1521-
- name: ROUTER_METRICS_TYPE
1522-
value: haproxy
1488+
$ curl admin:[email protected]:1936/metrics
15231489
----
1524-
====
1525-
Where 1936 is the STATS_PORT value.
1526-
1527-
[NOTE]
1528-
====
1529-
The `--expose-metrics` and `--metrics-image` options are deprecated. The haproxy-exporter
1530-
side car is now integrated into the router controller so you can delete the sidecar container from existing
1531-
router deployment configs. You can continue to use the side car in existing routers. New routers use the integrated metrics.
1532-
====
1533-
1534-
1535-
You can extract the raw statistics in Prometheus format by using the following.
1536-
1537-
Information needed to access the metrics is found the router service annotations:
1538-
1539-
====
1490+
+
1491+
You can get the information you need to access the metrics from the router service annotations:
1492+
+
15401493
----
1494+
$ oc edit router service <router-service-name>
1495+
1496+
apiVersion: v1
1497+
kind: Service
15411498
metadata:
15421499
annotations:
15431500
prometheus.io/port: "1936"
15441501
prometheus.io/scrape: "true"
15451502
prometheus.openshift.io/password: IImoDqON02
15461503
prometheus.openshift.io/username: admin
15471504
----
1548-
====
1549-
1550-
The metrics port is set from the STATS_PORT, default 1936. You may need to confiugre your firewall to permit access.
1551-
Use the above username and password to access the metrics. The path is "/metrics".
1552-
1505+
+
1506+
The `prometheus.io/port` is the stats port, by default 1936. You might need to configure your firewall to permit access.
1507+
Use the previous user name and password to access the metrics. The path is *_/metrics_*.
1508+
+
15531509
----
1554-
$ curl <user>:<password>@<router_IP>:<STATS_PORT>/metrics
1510+
$ curl <user>:<password>@<router_IP>:<STATS_PORT>
15551511
for example:
15561512
$ curl admin:[email protected]:1936/metrics
15571513
...
@@ -1581,6 +1537,45 @@ haproxy_server_bytes_in_total{namespace="default",pod="hello-rc-vkjqx",route="he
15811537
...
15821538
----
15831539

1540+
* To get metrics in a browser:
1541+
+
1542+
. Delete the following xref:../../architecture/networking/routes.adoc#env-variables[environment variables]
1543+
from the router deployment configuration file:
1544+
+
1545+
----
1546+
$ oc edit service router
1547+
1548+
- name: ROUTER_LISTEN_ADDR
1549+
value: 0.0.0.0:1936
1550+
- name: ROUTER_METRICS_TYPE
1551+
value: haproxy
1552+
----
1553+
+
1554+
. Launch the stats window using the following URL in a browser, where the `STATS_PORT` value is `1936` by default:
1555+
+
1556+
----
1557+
http://admin:<Password>@<router_IP>:<STATS_PORT>
1558+
----
1559+
+
1560+
You can get the stats in CSV format by adding `;csv` to the URL:
1561+
+
1562+
For example:
1563+
+
1564+
----
1565+
http://admin:<Password>@<router_IP>:1936;csv
1566+
----
1567+
+
1568+
To get the router IP, admin name, and password:
1569+
+
1570+
----
1571+
oc describe pod <router_pod>
1572+
----
1573+
1574+
* To suppress metrics collection:
1575+
+
1576+
----
1577+
$ oc adm router --service-account=router --stats-port=0
1578+
----
15841579

15851580
[[preventing-connection-failures-during-restarts]]
15861581
== Preventing Connection Failures During Restarts
@@ -1591,6 +1586,7 @@ dropped. The issue is being addressed. In the meantime, it is possible to work
15911586
around the problem by installing `iptables` rules to prevent connections during
15921587
the reload window. However, doing so means that the router needs to run with
15931588
elevated privilege so that it can manipulate `iptables` on the host. It also
1589+
15941590
means that connections that happen during the reload are temporarily ignored and
15951591
must retransmit their connection start, lengthening the time it takes to
15961592
connect, but preventing connection failure.
@@ -1623,11 +1619,9 @@ $ oc patch dc router -p '{"spec":{"template":{"spec":{"containers":[{"name":"rou
16231619

16241620
Set the option on the router deployment configuration:
16251621

1626-
====
16271622
----
16281623
$ oc set env dc/router -c router DROP_SYN_DURING_RESTART=true
16291624
----
1630-
====
16311625

16321626
If you used a non-default name for the router, you must change *_dc/router_*
16331627
accordingly.
@@ -1690,7 +1684,6 @@ Add *timeout http-request* to the default HAProxy router image to
16901684
protect the deployment against distributed denial-of-service (DDoS) attacks (for
16911685
example, slowloris):
16921686

1693-
====
16941687
----
16951688
# and the haproxy stats socket is available at /var/run/haproxy.stats
16961689
global
@@ -1707,7 +1700,6 @@ defaults
17071700
<1> *timeout http-request* is set up to 5 seconds. HAProxy gives a client 5 seconds
17081701
*to send its whole HTTP request. Otherwise, HAProxy shuts the connection with
17091702
*an error.
1710-
====
17111703

17121704
Also, when the environment variable `*ROUTER_SLOWLORIS_TIMEOUT*` is set, it
17131705
limits the amount of time a client has to send the whole HTTP request.

0 commit comments

Comments
 (0)