@@ -360,7 +360,6 @@ The following example creates a router deployment with `0` replicas and
360
360
customizes the router service HTTP and HTTPS ports, then scales it
361
361
appropriately (to `1` replica).
362
362
363
- ====
364
363
----
365
364
$ oc adm router --replicas=0 --ports='10080:10080,10443:10443' //<1>
366
365
$ oc set env dc/router ROUTER_SERVICE_HTTP_PORT=10080 \
@@ -369,7 +368,6 @@ $ oc scale dc/router --replicas=1
369
368
----
370
369
<1> Ensures exposed ports are appropriately set for routers that use the
371
370
container networking mode `--host-network=false`.
372
- ====
373
371
374
372
[IMPORTANT]
375
373
====
@@ -382,13 +380,10 @@ that you use via `firewall-cmd`).
382
380
The following is an example using `iptables` to open the custom router service
383
381
ports.
384
382
385
- ====
386
383
----
387
384
$ iptables -A INPUT -p tcp --dport 10080 -j ACCEPT
388
385
$ iptables -A INPUT -p tcp --dport 10443 -j ACCEPT
389
386
----
390
- ====
391
-
392
387
393
388
[[working-with-multiple-routers]]
394
389
== Working With Multiple Routers
@@ -431,7 +426,6 @@ $ oc edit dc <deploymentConfigName>
431
426
Add the `template.spec.nodeSelector` field with a key and value
432
427
corresponding to the label:
433
428
+
434
- ====
435
429
----
436
430
...
437
431
template:
@@ -446,7 +440,6 @@ corresponding to the label:
446
440
----
447
441
<1> The key and value are `router` and `first`, respectively,
448
442
corresponding to the `router=first` label.
449
- ====
450
443
451
444
[[using-router-shards]]
452
445
== Using Router Shards
@@ -490,7 +483,6 @@ Separate DNS entries must resolve *.foo.com to the node hosting Router A and *.e
490
483
* `*.foo.com A IN 192.168.0.5`
491
484
* `*.example.com A IN 192.168.1.9`
492
485
493
-
494
486
*Router Sharding Examples*
495
487
496
488
This section describes router sharding using namespace and route labels.
@@ -653,7 +645,6 @@ Here is a convenience script *_mkshard_* that
653
645
illustrates how `oc adm router`, `oc set env`, and `oc scale`
654
646
can be used together to make a router shard.
655
647
656
- ====
657
648
[source,bash]
658
649
----
659
650
#!/bin/bash
@@ -673,7 +664,6 @@ oc scale $dc --replicas=3 //<5>
673
664
The selection expression is the value of
674
665
the `ROUTE_LABELS` environment variable.
675
666
<5> Scale it up.
676
- ====
677
667
678
668
Running *_mkshard_* several times creates several routers:
679
669
@@ -712,7 +702,6 @@ demonstrating how to change the selection expression.
712
702
Here is a convenience script *_modshard_* that modifies
713
703
an existing router to use a new selection expression:
714
704
715
- ====
716
705
[source,bash]
717
706
----
718
707
#!/bin/bash
@@ -735,7 +724,6 @@ oc scale $dc --replicas=3 //<5>
735
724
non-`ID` arguments to `modshard` must include the
736
725
environment variable name as well as its value.
737
726
<5> Scale it back up.
738
- ====
739
727
740
728
[NOTE]
741
729
====
@@ -875,12 +863,10 @@ this default routing subdomain.
875
863
The following example shows how you can set the configured suffix
876
864
to *v3.openshift.test*:
877
865
878
- ====
879
866
----
880
867
routingConfig:
881
868
subdomain: v3.openshift.test
882
869
----
883
- ====
884
870
885
871
[NOTE]
886
872
====
@@ -892,11 +878,9 @@ xref:../../architecture/networking/routes.adoc#route-hostnames[generated host
892
878
name] for the example of a route named *no-route-hostname* without a
893
879
host name added to a namespace *mynamespace* would be:
894
880
895
- ====
896
881
----
897
882
no-route-hostname-mynamespace.v3.openshift.test
898
883
----
899
- ====
900
884
901
885
[[forcing-route-hostnames-to-a-custom-routing-subdomain]]
902
886
== Forcing Route Host Names to a Custom Routing Subdomain
@@ -909,11 +893,9 @@ a route and generate one based on the template provided to the
909
893
The following example runs a router, which overrides the route host names using
910
894
a custom subdomain template `${name}-${namespace}.apps.example.com`.
911
895
912
- ====
913
896
----
914
897
$ oc adm router --force-subdomain='${name}-${namespace}.apps.example.com'
915
898
----
916
- ====
917
899
918
900
[[using-wildcard-certificates]]
919
901
== Using Wildcard Certificates
@@ -923,15 +905,13 @@ default certificate instead. In most cases, this certificate should be provided
923
905
by a trusted certificate authority, but for convenience you can use the
924
906
{product-title} CA to create the certificate. For example:
925
907
926
- ====
927
908
----
928
909
$ CA=/etc/origin/master
929
910
$ oc adm ca create-server-cert --signer-cert=$CA/ca.crt \
930
911
--signer-key=$CA/ca.key --signer-serial=$CA/ca.serial.txt \
931
912
--hostnames='*.cloudapps.example.com' \
932
913
--cert=cloudapps.crt --key=cloudapps.key
933
914
----
934
- ====
935
915
936
916
[NOTE]
937
917
====
@@ -946,19 +926,15 @@ by default *_/etc/ansible/hosts_*.
946
926
The router expects the certificate and key to be in PEM format in a single
947
927
file:
948
928
949
- ====
950
929
----
951
930
$ cat cloudapps.crt cloudapps.key $CA/ca.crt > cloudapps.router.pem
952
931
----
953
- ====
954
932
955
933
From there you can use the `--default-cert` flag:
956
934
957
- ====
958
935
----
959
936
$ oc adm router --default-cert=cloudapps.router.pem --service-account=router
960
937
----
961
- ====
962
938
963
939
[NOTE]
964
940
====
@@ -1109,7 +1085,6 @@ DNS lookup:
1109
1085
# curl -k --resolve www.example.test:443:$routerip https://www.example.test/
1110
1086
----
1111
1087
1112
-
1113
1088
[[using-wildcard-routes]]
1114
1089
== Using Wildcard Routes (for a Subdomain)
1115
1090
@@ -1443,18 +1418,14 @@ stack, use the `--host-network=false` option when creating the router. For
1443
1418
example:
1444
1419
1445
1420
ifdef::openshift-enterprise[]
1446
- ====
1447
1421
----
1448
1422
$ oc adm router --service-account=router --host-network=false
1449
1423
----
1450
- ====
1451
1424
endif::[]
1452
1425
ifdef::openshift-origin[]
1453
- ====
1454
1426
----
1455
1427
$ oc adm router --service-account=router --host-network=false
1456
1428
----
1457
- ====
1458
1429
endif::[]
1459
1430
1460
1431
Internally, this means the router container must publish the 80 and 443
@@ -1479,7 +1450,6 @@ access any pod in the cluster. If isolation is needed in this case, then do not
1479
1450
add routes across the namespaces.
1480
1451
====
1481
1452
1482
-
1483
1453
[[exposing-the-router-metrics]]
1484
1454
== Exposing Router Metrics
1485
1455
@@ -1488,55 +1458,49 @@ xref:../../architecture/networking/assembly_available_router_plugins.adoc#haprox
1488
1458
are, by default, exposed or published in
1489
1459
link:https://prometheus.io/docs/concepts/data_model/[Prometheus format]
1490
1460
for consumption by external metrics collection and aggregation systems (e.g. Prometheus, statsd).
1491
- Metrics are also available dirctly from the
1492
- link:https://cbonte.github.io/haproxy-dconv/1.5/configuration.html#9[HAProxy router] in its own CSV format.
1461
+ Metrics are also available directly from the
1462
+ link:https://cbonte.github.io/haproxy-dconv/1.5/configuration.html#9[HAProxy router] in its own HTML format for viewing in a browser
1463
+ or CSV download.
1464
+ These metrics include the HAProxy native metrics and some controller metrics.
1465
+
1466
+ When you create a router using the following command, {product-title} makes metrics available in Prometheus format on the stats port, by default 1936.
1493
1467
1494
- When you create a router, as below,
1495
- ====
1496
1468
----
1497
1469
$ oc adm router --service-account=router
1498
1470
----
1499
- ====
1500
- metrics are automatically available in Prometheus format on the stats-port, default 1936. To suppress metrics collection,
1501
- ====
1471
+
1472
+ * To extract the raw statistics in Prometheus format run the following command:
1473
+ +
1502
1474
----
1503
- $ oc adm router --service-account=router --stats-port=0
1475
+ curl <user>:<password>@<router_IP>:<STATS_PORT>
1504
1476
----
1505
- ====
1506
-
1507
- To switch to the HAProxy CSV format metrics, edit the xref:../../architecture/networking/routes.adoc#env-variables[environment variables]
1508
- for the router dc and delete the following lines:
1509
-
1510
- ====
1477
+ +
1478
+ For example:
1479
+ +
1511
1480
----
1512
- - name: ROUTER_LISTEN_ADDR
1513
- value: 0.0.0.0:1936
1514
- - name: ROUTER_METRICS_TYPE
1515
- value: haproxy
1481
+ $ curl admin:[email protected] :1936/metrics
1516
1482
----
1517
- ====
1518
- Where 1936 is the STATS_PORT value.
1519
-
1520
- You can extract the raw statistics in Prometheus format by using the following.
1521
-
1522
- Information needed to access the metrics is found the router service annotations:
1523
-
1524
- ====
1483
+ +
1484
+ You can get the information you need to access the metrics from the router service annotations:
1485
+ +
1525
1486
----
1487
+ $ oc edit router service <router-service-name>
1488
+
1489
+ apiVersion: v1
1490
+ kind: Service
1526
1491
metadata:
1527
1492
annotations:
1528
1493
prometheus.io/port: "1936"
1529
1494
prometheus.io/scrape: "true"
1530
1495
prometheus.openshift.io/password: IImoDqON02
1531
1496
prometheus.openshift.io/username: admin
1532
1497
----
1533
- ====
1534
-
1535
- The metrics port is set from the STATS_PORT, default 1936. You may need to confiugre your firewall to permit access.
1536
- Use the above username and password to access the metrics. The path is "/metrics".
1537
-
1498
+ +
1499
+ The `prometheus.io/port` is the stats port, by default 1936. You might need to configure your firewall to permit access.
1500
+ Use the previous user name and password to access the metrics. The path is *_/metrics_*.
1501
+ +
1538
1502
----
1539
- $ curl <user>:<password>@<router_IP>:<STATS_PORT>/metrics
1503
+ $ curl <user>:<password>@<router_IP>:<STATS_PORT>
1540
1504
for example:
1541
1505
$ curl admin:[email protected] :1936/metrics
1542
1506
...
@@ -1566,6 +1530,45 @@ haproxy_server_bytes_in_total{namespace="default",pod="hello-rc-vkjqx",route="he
1566
1530
...
1567
1531
----
1568
1532
1533
+ * To get metrics in a browser:
1534
+ +
1535
+ . Delete the following xref:../../architecture/networking/routes.adoc#env-variables[environment variables]
1536
+ from the router deployment configuration file:
1537
+ +
1538
+ ----
1539
+ $ oc edit service router
1540
+
1541
+ - name: ROUTER_LISTEN_ADDR
1542
+ value: 0.0.0.0:1936
1543
+ - name: ROUTER_METRICS_TYPE
1544
+ value: haproxy
1545
+ ----
1546
+ +
1547
+ . Launch the stats window using the following URL in a browser, where the `STATS_PORT` value is `1936` by default:
1548
+ +
1549
+ ----
1550
+ http://admin:<Password>@<router_IP>:<STATS_PORT>
1551
+ ----
1552
+ +
1553
+ You can get the stats in CSV format by adding `;csv` to the URL:
1554
+ +
1555
+ For example:
1556
+ +
1557
+ ----
1558
+ http://admin:<Password>@<router_IP>:1936;csv
1559
+ ----
1560
+ +
1561
+ To get the router IP, admin name, and password:
1562
+ +
1563
+ ----
1564
+ oc describe pod <router_pod>
1565
+ ----
1566
+
1567
+ * To suppress metrics collection:
1568
+ +
1569
+ ----
1570
+ $ oc adm router --service-account=router --stats-port=0
1571
+ ----
1569
1572
1570
1573
[[preventing-connection-failures-during-restarts]]
1571
1574
== Preventing Connection Failures During Restarts
@@ -1576,6 +1579,7 @@ dropped. The issue is being addressed. In the meantime, it is possible to work
1576
1579
around the problem by installing `iptables` rules to prevent connections during
1577
1580
the reload window. However, doing so means that the router needs to run with
1578
1581
elevated privilege so that it can manipulate `iptables` on the host. It also
1582
+
1579
1583
means that connections that happen during the reload are temporarily ignored and
1580
1584
must retransmit their connection start, lengthening the time it takes to
1581
1585
connect, but preventing connection failure.
@@ -1608,11 +1612,9 @@ $ oc patch dc router -p '{"spec":{"template":{"spec":{"containers":[{"name":"rou
1608
1612
1609
1613
Set the option on the router deployment configuration:
1610
1614
1611
- ====
1612
1615
----
1613
1616
$ oc set env dc/router -c router DROP_SYN_DURING_RESTART=1
1614
1617
----
1615
- ====
1616
1618
1617
1619
If you used a non-default name for the router, you must change *_dc/router_*
1618
1620
accordingly.
@@ -1675,7 +1677,6 @@ Add *timeout http-request* to the default HAProxy router image to
1675
1677
protect the deployment against distributed denial-of-service (DDoS) attacks (for
1676
1678
example, slowloris):
1677
1679
1678
- ====
1679
1680
----
1680
1681
# and the haproxy stats socket is available at /var/run/haproxy.stats
1681
1682
global
@@ -1692,7 +1693,6 @@ defaults
1692
1693
<1> *timeout http-request* is set up to 5 seconds. HAProxy gives a client 5 seconds
1693
1694
*to send its whole HTTP request. Otherwise, HAProxy shuts the connection with
1694
1695
*an error.
1695
- ====
1696
1696
1697
1697
Also, when the environment variable `*ROUTER_SLOWLORIS_TIMEOUT*` is set, it
1698
1698
limits the amount of time a client has to send the whole HTTP request.
0 commit comments