@@ -359,7 +359,6 @@ The following example creates a router deployment with `0` replicas and
359
359
customizes the router service HTTP and HTTPS ports, then scales it
360
360
appropriately (to `1` replica).
361
361
362
- ====
363
362
----
364
363
$ oc adm router --replicas=0 --ports='10080:10080,10443:10443' //<1>
365
364
$ oc set env dc/router ROUTER_SERVICE_HTTP_PORT=10080 \
@@ -368,7 +367,6 @@ $ oc scale dc/router --replicas=1
368
367
----
369
368
<1> Ensures exposed ports are appropriately set for routers that use the
370
369
container networking mode `--host-network=false`.
371
- ====
372
370
373
371
[IMPORTANT]
374
372
====
@@ -381,13 +379,10 @@ that you use via `firewall-cmd`).
381
379
The following is an example using `iptables` to open the custom router service
382
380
ports.
383
381
384
- ====
385
382
----
386
383
$ iptables -A INPUT -p tcp --dport 10080 -j ACCEPT
387
384
$ iptables -A INPUT -p tcp --dport 10443 -j ACCEPT
388
385
----
389
- ====
390
-
391
386
392
387
[[working-with-multiple-routers]]
393
388
== Working With Multiple Routers
@@ -430,7 +425,6 @@ $ oc edit dc <deploymentConfigName>
430
425
Add the `template.spec.nodeSelector` field with a key and value
431
426
corresponding to the label:
432
427
+
433
- ====
434
428
----
435
429
...
436
430
template:
@@ -445,7 +439,6 @@ corresponding to the label:
445
439
----
446
440
<1> The key and value are `router` and `first`, respectively,
447
441
corresponding to the `router=first` label.
448
- ====
449
442
450
443
[[using-router-shards]]
451
444
== Using Router Shards
@@ -489,7 +482,6 @@ Separate DNS entries must resolve *.foo.com to the node hosting Router A and *.e
489
482
* `*.foo.com A IN 192.168.0.5`
490
483
* `*.example.com A IN 192.168.1.9`
491
484
492
-
493
485
*Router Sharding Examples*
494
486
495
487
This section describes router sharding using namespace and route labels.
@@ -652,7 +644,6 @@ Here is a convenience script *_mkshard_* that
652
644
illustrates how `oc adm router`, `oc set env`, and `oc scale`
653
645
can be used together to make a router shard.
654
646
655
- ====
656
647
[source,bash]
657
648
----
658
649
#!/bin/bash
@@ -672,7 +663,6 @@ oc scale $dc --replicas=3 //<5>
672
663
The selection expression is the value of
673
664
the `ROUTE_LABELS` environment variable.
674
665
<5> Scale it up.
675
- ====
676
666
677
667
Running *_mkshard_* several times creates several routers:
678
668
@@ -711,7 +701,6 @@ demonstrating how to change the selection expression.
711
701
Here is a convenience script *_modshard_* that modifies
712
702
an existing router to use a new selection expression:
713
703
714
- ====
715
704
[source,bash]
716
705
----
717
706
#!/bin/bash
@@ -734,7 +723,6 @@ oc scale $dc --replicas=3 //<5>
734
723
non-`ID` arguments to `modshard` must include the
735
724
environment variable name as well as its value.
736
725
<5> Scale it back up.
737
- ====
738
726
739
727
[NOTE]
740
728
====
@@ -874,12 +862,10 @@ this default routing subdomain.
874
862
The following example shows how you can set the configured suffix
875
863
to *v3.openshift.test*:
876
864
877
- ====
878
865
----
879
866
routingConfig:
880
867
subdomain: v3.openshift.test
881
868
----
882
- ====
883
869
884
870
[NOTE]
885
871
====
@@ -891,11 +877,9 @@ xref:../../architecture/networking/routes.adoc#route-hostnames[generated host
891
877
name] for the example of a route named *no-route-hostname* without a
892
878
host name added to a namespace *mynamespace* would be:
893
879
894
- ====
895
880
----
896
881
no-route-hostname-mynamespace.v3.openshift.test
897
882
----
898
- ====
899
883
900
884
[[forcing-route-hostnames-to-a-custom-routing-subdomain]]
901
885
== 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
908
892
The following example runs a router, which overrides the route host names using
909
893
a custom subdomain template `${name}-${namespace}.apps.example.com`.
910
894
911
- ====
912
895
----
913
896
$ oc adm router --force-subdomain='${name}-${namespace}.apps.example.com'
914
897
----
915
- ====
916
898
917
899
[[using-wildcard-certificates]]
918
900
== Using Wildcard Certificates
@@ -922,15 +904,13 @@ default certificate instead. In most cases, this certificate should be provided
922
904
by a trusted certificate authority, but for convenience you can use the
923
905
{product-title} CA to create the certificate. For example:
924
906
925
- ====
926
907
----
927
908
$ CA=/etc/origin/master
928
909
$ oc adm ca create-server-cert --signer-cert=$CA/ca.crt \
929
910
--signer-key=$CA/ca.key --signer-serial=$CA/ca.serial.txt \
930
911
--hostnames='*.cloudapps.example.com' \
931
912
--cert=cloudapps.crt --key=cloudapps.key
932
913
----
933
- ====
934
914
935
915
[NOTE]
936
916
====
@@ -945,19 +925,15 @@ by default *_/etc/ansible/hosts_*.
945
925
The router expects the certificate and key to be in PEM format in a single
946
926
file:
947
927
948
- ====
949
928
----
950
929
$ cat cloudapps.crt cloudapps.key $CA/ca.crt > cloudapps.router.pem
951
930
----
952
- ====
953
931
954
932
From there you can use the `--default-cert` flag:
955
933
956
- ====
957
934
----
958
935
$ oc adm router --default-cert=cloudapps.router.pem --service-account=router
959
936
----
960
- ====
961
937
962
938
[NOTE]
963
939
====
@@ -1108,7 +1084,6 @@ DNS lookup:
1108
1084
# curl -k --resolve www.example.test:443:$routerip https://www.example.test/
1109
1085
----
1110
1086
1111
-
1112
1087
[[using-wildcard-routes]]
1113
1088
== Using Wildcard Routes (for a Subdomain)
1114
1089
@@ -1450,18 +1425,14 @@ stack, use the `--host-network=false` option when creating the router. For
1450
1425
example:
1451
1426
1452
1427
ifdef::openshift-enterprise[]
1453
- ====
1454
1428
----
1455
1429
$ oc adm router --service-account=router --host-network=false
1456
1430
----
1457
- ====
1458
1431
endif::[]
1459
1432
ifdef::openshift-origin[]
1460
- ====
1461
1433
----
1462
1434
$ oc adm router --service-account=router --host-network=false
1463
1435
----
1464
- ====
1465
1436
endif::[]
1466
1437
1467
1438
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
1486
1457
add routes across the namespaces.
1487
1458
====
1488
1459
1489
-
1490
1460
[[exposing-the-router-metrics]]
1491
1461
== Exposing Router Metrics
1492
1462
@@ -1495,55 +1465,49 @@ xref:../../architecture/networking/assembly_available_router_plugins.adoc#haprox
1495
1465
are, by default, exposed or published in
1496
1466
link:https://prometheus.io/docs/concepts/data_model/[Prometheus format]
1497
1467
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.
1500
1474
1501
- When you create a router, as below,
1502
- ====
1503
1475
----
1504
1476
$ oc adm router --service-account=router
1505
1477
----
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
+ +
1509
1481
----
1510
- $ oc adm router --service-account=router --stats-port=0
1482
+ curl <user>:<password>@<router_IP>:<STATS_PORT>
1511
1483
----
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
+ +
1518
1487
----
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
1523
1489
----
1524
- ====
1525
- Where 1936 is the STATS_PORT value.
1526
-
1527
- You can extract the raw statistics in Prometheus format by using the following.
1528
-
1529
- Information needed to access the metrics is found the router service annotations:
1530
-
1531
- ====
1490
+ +
1491
+ You can get the information you need to access the metrics from the router service annotations:
1492
+ +
1532
1493
----
1494
+ $ oc edit router service <router-service-name>
1495
+
1496
+ apiVersion: v1
1497
+ kind: Service
1533
1498
metadata:
1534
1499
annotations:
1535
1500
prometheus.io/port: "1936"
1536
1501
prometheus.io/scrape: "true"
1537
1502
prometheus.openshift.io/password: IImoDqON02
1538
1503
prometheus.openshift.io/username: admin
1539
1504
----
1540
- ====
1541
-
1542
- The metrics port is set from the STATS_PORT, default 1936. You may need to confiugre your firewall to permit access.
1543
- Use the above username and password to access the metrics. The path is "/metrics".
1544
-
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
+ +
1545
1509
----
1546
- $ curl <user>:<password>@<router_IP>:<STATS_PORT>/metrics
1510
+ $ curl <user>:<password>@<router_IP>:<STATS_PORT>
1547
1511
for example:
1548
1512
$ curl admin:[email protected] :1936/metrics
1549
1513
...
@@ -1573,6 +1537,45 @@ haproxy_server_bytes_in_total{namespace="default",pod="hello-rc-vkjqx",route="he
1573
1537
...
1574
1538
----
1575
1539
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
+ ----
1576
1579
1577
1580
[[preventing-connection-failures-during-restarts]]
1578
1581
== Preventing Connection Failures During Restarts
@@ -1583,6 +1586,7 @@ dropped. The issue is being addressed. In the meantime, it is possible to work
1583
1586
around the problem by installing `iptables` rules to prevent connections during
1584
1587
the reload window. However, doing so means that the router needs to run with
1585
1588
elevated privilege so that it can manipulate `iptables` on the host. It also
1589
+
1586
1590
means that connections that happen during the reload are temporarily ignored and
1587
1591
must retransmit their connection start, lengthening the time it takes to
1588
1592
connect, but preventing connection failure.
@@ -1615,11 +1619,9 @@ $ oc patch dc router -p '{"spec":{"template":{"spec":{"containers":[{"name":"rou
1615
1619
1616
1620
Set the option on the router deployment configuration:
1617
1621
1618
- ====
1619
1622
----
1620
1623
$ oc set env dc/router -c router DROP_SYN_DURING_RESTART=1
1621
1624
----
1622
- ====
1623
1625
1624
1626
If you used a non-default name for the router, you must change *_dc/router_*
1625
1627
accordingly.
@@ -1682,7 +1684,6 @@ Add *timeout http-request* to the default HAProxy router image to
1682
1684
protect the deployment against distributed denial-of-service (DDoS) attacks (for
1683
1685
example, slowloris):
1684
1686
1685
- ====
1686
1687
----
1687
1688
# and the haproxy stats socket is available at /var/run/haproxy.stats
1688
1689
global
@@ -1699,7 +1700,6 @@ defaults
1699
1700
<1> *timeout http-request* is set up to 5 seconds. HAProxy gives a client 5 seconds
1700
1701
*to send its whole HTTP request. Otherwise, HAProxy shuts the connection with
1701
1702
*an error.
1702
- ====
1703
1703
1704
1704
Also, when the environment variable `*ROUTER_SLOWLORIS_TIMEOUT*` is set, it
1705
1705
limits the amount of time a client has to send the whole HTTP request.
0 commit comments