@@ -365,7 +365,6 @@ The following example creates a router deployment with `0` replicas and
365
365
customizes the router service HTTP and HTTPS ports, then scales it
366
366
appropriately (to `1` replica).
367
367
368
- ====
369
368
----
370
369
$ oc adm router --replicas=0 --ports='10080:10080,10443:10443' //<1>
371
370
$ oc set env dc/router ROUTER_SERVICE_HTTP_PORT=10080 \
@@ -374,7 +373,6 @@ $ oc scale dc/router --replicas=1
374
373
----
375
374
<1> Ensures exposed ports are appropriately set for routers that use the
376
375
container networking mode `--host-network=false`.
377
- ====
378
376
379
377
[IMPORTANT]
380
378
====
@@ -387,12 +385,10 @@ that you use via `firewall-cmd`).
387
385
The following is an example using `iptables` to open the custom router service
388
386
ports.
389
387
390
- ====
391
388
----
392
389
$ iptables -A INPUT -p tcp --dport 10080 -j ACCEPT
393
390
$ iptables -A INPUT -p tcp --dport 10443 -j ACCEPT
394
391
----
395
- ====
396
392
397
393
[[working-with-multiple-routers]]
398
394
== Working With Multiple Routers
@@ -435,7 +431,6 @@ $ oc edit dc <deploymentConfigName>
435
431
Add the `template.spec.nodeSelector` field with a key and value
436
432
corresponding to the label:
437
433
+
438
- ====
439
434
----
440
435
...
441
436
template:
@@ -450,7 +445,6 @@ corresponding to the label:
450
445
----
451
446
<1> The key and value are `router` and `first`, respectively,
452
447
corresponding to the `router=first` label.
453
- ====
454
448
455
449
[[using-router-shards]]
456
450
== Using Router Shards
@@ -494,7 +488,6 @@ Separate DNS entries must resolve *.foo.com to the node hosting Router A and *.e
494
488
* `*.foo.com A IN 192.168.0.5`
495
489
* `*.example.com A IN 192.168.1.9`
496
490
497
-
498
491
*Router Sharding Examples*
499
492
500
493
This section describes router sharding using namespace and route labels.
@@ -657,7 +650,6 @@ Here is a convenience script *_mkshard_* that
657
650
illustrates how `oc adm router`, `oc set env`, and `oc scale`
658
651
can be used together to make a router shard.
659
652
660
- ====
661
653
[source,bash]
662
654
----
663
655
#!/bin/bash
@@ -677,7 +669,6 @@ oc scale $dc --replicas=3 //<5>
677
669
The selection expression is the value of
678
670
the `ROUTE_LABELS` environment variable.
679
671
<5> Scale it up.
680
- ====
681
672
682
673
Running *_mkshard_* several times creates several routers:
683
674
@@ -716,7 +707,6 @@ demonstrating how to change the selection expression.
716
707
Here is a convenience script *_modshard_* that modifies
717
708
an existing router to use a new selection expression:
718
709
719
- ====
720
710
[source,bash]
721
711
----
722
712
#!/bin/bash
@@ -739,7 +729,6 @@ oc scale $dc --replicas=3 //<5>
739
729
non-`ID` arguments to `modshard` must include the
740
730
environment variable name as well as its value.
741
731
<5> Scale it back up.
742
- ====
743
732
744
733
[NOTE]
745
734
====
@@ -879,12 +868,10 @@ this default routing subdomain.
879
868
The following example shows how you can set the configured suffix
880
869
to *v3.openshift.test*:
881
870
882
- ====
883
871
----
884
872
routingConfig:
885
873
subdomain: v3.openshift.test
886
874
----
887
- ====
888
875
889
876
[NOTE]
890
877
====
@@ -896,11 +883,9 @@ xref:../../architecture/networking/routes.adoc#route-hostnames[generated host
896
883
name] for the example of a route named *no-route-hostname* without a
897
884
host name added to a namespace *mynamespace* would be:
898
885
899
- ====
900
886
----
901
887
no-route-hostname-mynamespace.v3.openshift.test
902
888
----
903
- ====
904
889
905
890
[[forcing-route-hostnames-to-a-custom-routing-subdomain]]
906
891
== Forcing Route Host Names to a Custom Routing Subdomain
@@ -913,11 +898,9 @@ a route and generate one based on the template provided to the
913
898
The following example runs a router, which overrides the route host names using
914
899
a custom subdomain template `${name}-${namespace}.apps.example.com`.
915
900
916
- ====
917
901
----
918
902
$ oc adm router --force-subdomain='${name}-${namespace}.apps.example.com'
919
903
----
920
- ====
921
904
922
905
[[using-wildcard-certificates]]
923
906
== Using Wildcard Certificates
@@ -927,15 +910,13 @@ default certificate instead. In most cases, this certificate should be provided
927
910
by a trusted certificate authority, but for convenience you can use the
928
911
{product-title} CA to create the certificate. For example:
929
912
930
- ====
931
913
----
932
914
$ CA=/etc/origin/master
933
915
$ oc adm ca create-server-cert --signer-cert=$CA/ca.crt \
934
916
--signer-key=$CA/ca.key --signer-serial=$CA/ca.serial.txt \
935
917
--hostnames='*.cloudapps.example.com' \
936
918
--cert=cloudapps.crt --key=cloudapps.key
937
919
----
938
- ====
939
920
940
921
[NOTE]
941
922
====
@@ -950,19 +931,15 @@ by default *_/etc/ansible/hosts_*.
950
931
The router expects the certificate and key to be in PEM format in a single
951
932
file:
952
933
953
- ====
954
934
----
955
935
$ cat cloudapps.crt cloudapps.key $CA/ca.crt > cloudapps.router.pem
956
936
----
957
- ====
958
937
959
938
From there you can use the `--default-cert` flag:
960
939
961
- ====
962
940
----
963
941
$ oc adm router --default-cert=cloudapps.router.pem --service-account=router
964
942
----
965
- ====
966
943
967
944
[NOTE]
968
945
====
@@ -1113,7 +1090,6 @@ DNS lookup:
1113
1090
# curl -k --resolve www.example.test:443:$routerip https://www.example.test/
1114
1091
----
1115
1092
1116
-
1117
1093
[[using-wildcard-routes]]
1118
1094
== Using Wildcard Routes (for a Subdomain)
1119
1095
@@ -1455,18 +1431,14 @@ stack, use the `--host-network=false` option when creating the router. For
1455
1431
example:
1456
1432
1457
1433
ifdef::openshift-enterprise[]
1458
- ====
1459
1434
----
1460
1435
$ oc adm router --service-account=router --host-network=false
1461
1436
----
1462
- ====
1463
1437
endif::[]
1464
1438
ifdef::openshift-origin[]
1465
- ====
1466
1439
----
1467
1440
$ oc adm router --service-account=router --host-network=false
1468
1441
----
1469
- ====
1470
1442
endif::[]
1471
1443
1472
1444
Internally, this means the router container must publish the 80 and 443
@@ -1491,7 +1463,6 @@ access any pod in the cluster. If isolation is needed in this case, then do not
1491
1463
add routes across the namespaces.
1492
1464
====
1493
1465
1494
-
1495
1466
[[exposing-the-router-metrics]]
1496
1467
== Exposing Router Metrics
1497
1468
@@ -1500,63 +1471,49 @@ xref:../../architecture/networking/assembly_available_router_plugins.adoc#haprox
1500
1471
are, by default, exposed or published in
1501
1472
link:https://prometheus.io/docs/concepts/data_model/[Prometheus format]
1502
1473
for consumption by external metrics collection and aggregation systems (e.g. Prometheus, statsd).
1503
- Metrics are also available dirctly from the
1504
- link:https://cbonte.github.io/haproxy-dconv/1.5/configuration.html#9[HAProxy router] in its own CSV format.
1474
+ Metrics are also available directly from the
1475
+ link:https://cbonte.github.io/haproxy-dconv/1.5/configuration.html#9[HAProxy router] in its own HTML format for viewing in a browser
1476
+ or CSV download.
1477
+ These metrics include the HAProxy native metrics and some controller metrics.
1478
+
1479
+ When you create a router using the following command, {product-title} makes metrics available in Prometheus format on the stats port, by default 1936.
1505
1480
1506
- When you create a router, as below,
1507
- ====
1508
1481
----
1509
1482
$ oc adm router --service-account=router
1510
1483
----
1511
- ====
1512
- metrics are automatically available in Prometheus format on the stats-port, default 1936. To suppress metrics collection,
1513
- ====
1484
+
1485
+ * To extract the raw statistics in Prometheus format run the following command:
1486
+ +
1514
1487
----
1515
- $ oc adm router --service-account=router --stats-port=0
1488
+ curl <user>:<password>@<router_IP>:<STATS_PORT>
1516
1489
----
1517
- ====
1518
-
1519
- To switch to the HAProxy CSV format metrics, edit the xref:../../architecture/networking/routes.adoc#env-variables[environment variables]
1520
- for the router dc and delete the following lines:
1521
-
1522
- ====
1490
+ +
1491
+ For example:
1492
+ +
1523
1493
----
1524
- - name: ROUTER_LISTEN_ADDR
1525
- value: 0.0.0.0:1936
1526
- - name: ROUTER_METRICS_TYPE
1527
- value: haproxy
1494
+ $ curl admin:[email protected] :1936/metrics
1528
1495
----
1529
- ====
1530
- Where 1936 is the STATS_PORT value.
1531
-
1532
- [NOTE]
1533
- ====
1534
- The `--expose-metrics` and `--metrics-image` options are deprecated. The haproxy-exporter
1535
- side car is now integrated into the router controller so you can delete the sidecar container from existing
1536
- router deployment configs. You can continue to use the side car in existing routers. New routers use the integrated metrics.
1537
- ====
1538
-
1539
-
1540
- You can extract the raw statistics in Prometheus format by using the following.
1541
-
1542
- Information needed to access the metrics is found the router service annotations:
1543
-
1544
- ====
1496
+ +
1497
+ You can get the information you need to access the metrics from the router service annotations:
1498
+ +
1545
1499
----
1500
+ $ oc edit router service <router-service-name>
1501
+
1502
+ apiVersion: v1
1503
+ kind: Service
1546
1504
metadata:
1547
1505
annotations:
1548
1506
prometheus.io/port: "1936"
1549
1507
prometheus.io/scrape: "true"
1550
1508
prometheus.openshift.io/password: IImoDqON02
1551
1509
prometheus.openshift.io/username: admin
1552
1510
----
1553
- ====
1554
-
1555
- The metrics port is set from the STATS_PORT, default 1936. You may need to confiugre your firewall to permit access.
1556
- Use the above username and password to access the metrics. The path is "/metrics".
1557
-
1511
+ +
1512
+ The `prometheus.io/port` is the stats port, by default 1936. You might need to configure your firewall to permit access.
1513
+ Use the previous user name and password to access the metrics. The path is *_/metrics_*.
1514
+ +
1558
1515
----
1559
- $ curl <user>:<password>@<router_IP>:<STATS_PORT>/metrics
1516
+ $ curl <user>:<password>@<router_IP>:<STATS_PORT>
1560
1517
for example:
1561
1518
$ curl admin:[email protected] :1936/metrics
1562
1519
...
@@ -1586,6 +1543,45 @@ haproxy_server_bytes_in_total{namespace="default",pod="hello-rc-vkjqx",route="he
1586
1543
...
1587
1544
----
1588
1545
1546
+ * To get metrics in a browser:
1547
+ +
1548
+ . Delete the following xref:../../architecture/networking/routes.adoc#env-variables[environment variables]
1549
+ from the router deployment configuration file:
1550
+ +
1551
+ ----
1552
+ $ oc edit service router
1553
+
1554
+ - name: ROUTER_LISTEN_ADDR
1555
+ value: 0.0.0.0:1936
1556
+ - name: ROUTER_METRICS_TYPE
1557
+ value: haproxy
1558
+ ----
1559
+ +
1560
+ . Launch the stats window using the following URL in a browser, where the `STATS_PORT` value is `1936` by default:
1561
+ +
1562
+ ----
1563
+ http://admin:<Password>@<router_IP>:<STATS_PORT>
1564
+ ----
1565
+ +
1566
+ You can get the stats in CSV format by adding `;csv` to the URL:
1567
+ +
1568
+ For example:
1569
+ +
1570
+ ----
1571
+ http://admin:<Password>@<router_IP>:1936;csv
1572
+ ----
1573
+ +
1574
+ To get the router IP, admin name, and password:
1575
+ +
1576
+ ----
1577
+ oc describe pod <router_pod>
1578
+ ----
1579
+
1580
+ * To suppress metrics collection:
1581
+ +
1582
+ ----
1583
+ $ oc adm router --service-account=router --stats-port=0
1584
+ ----
1589
1585
1590
1586
[[preventing-connection-failures-during-restarts]]
1591
1587
== Preventing Connection Failures During Restarts
@@ -1596,6 +1592,7 @@ dropped. The issue is being addressed. In the meantime, it is possible to work
1596
1592
around the problem by installing `iptables` rules to prevent connections during
1597
1593
the reload window. However, doing so means that the router needs to run with
1598
1594
elevated privilege so that it can manipulate `iptables` on the host. It also
1595
+
1599
1596
means that connections that happen during the reload are temporarily ignored and
1600
1597
must retransmit their connection start, lengthening the time it takes to
1601
1598
connect, but preventing connection failure.
@@ -1628,11 +1625,9 @@ $ oc patch dc router -p '{"spec":{"template":{"spec":{"containers":[{"name":"rou
1628
1625
1629
1626
Set the option on the router deployment configuration:
1630
1627
1631
- ====
1632
1628
----
1633
1629
$ oc set env dc/router -c router DROP_SYN_DURING_RESTART=true
1634
1630
----
1635
- ====
1636
1631
1637
1632
If you used a non-default name for the router, you must change *_dc/router_*
1638
1633
accordingly.
@@ -1695,7 +1690,6 @@ Add *timeout http-request* to the default HAProxy router image to
1695
1690
protect the deployment against distributed denial-of-service (DDoS) attacks (for
1696
1691
example, slowloris):
1697
1692
1698
- ====
1699
1693
----
1700
1694
# and the haproxy stats socket is available at /var/run/haproxy.stats
1701
1695
global
@@ -1712,7 +1706,6 @@ defaults
1712
1706
<1> *timeout http-request* is set up to 5 seconds. HAProxy gives a client 5 seconds
1713
1707
*to send its whole HTTP request. Otherwise, HAProxy shuts the connection with
1714
1708
*an error.
1715
- ====
1716
1709
1717
1710
Also, when the environment variable `*ROUTER_SLOWLORIS_TIMEOUT*` is set, it
1718
1711
limits the amount of time a client has to send the whole HTTP request.
0 commit comments