Available router plug-ins
A router can be assigned to a node to control traffic in an OKD cluster. OKD uses HAProxy as the default router, but options are available.
The HAProxy Template Router
The HAProxy template router implementation is the reference implementation for a template router plug-in. It uses the openshift/origin-haproxy-router repository to run an HAProxy instance alongside the template router plug-in.
The template router has two components:
A wrapper that watches endpoints and routes and causes a HAProxy reload based on changes
A controller that builds the HAProxy configuration file based on routes and endpoints
The HAProxy router uses version 1.8.1. |
The controller and HAProxy are housed inside a pod, which is managed by a deployment configuration. The process of setting up the router is automated by the oc adm router
command.
The controller watches the routes and endpoints for changes, as well as HAProxy’s health. When a change is detected, it builds a new haproxy-config file and restarts HAProxy. The haproxy-config file is constructed based on the router’s template file and information from OKD.
The HAProxy template file can be customized as needed to support features that are not currently supported by OKD. The HAProxy manual describes all of the features supported by HAProxy.
The following diagram illustrates how data flows from the master through the plug-in and finally into an HAProxy configuration:
Figure 1. HAProxy Router Data Flow
HAProxy Template Router Metrics
The HAProxy router exposes or publishes metrics in Prometheus format for consumption by external metrics collection and aggregation systems (e.g. Prometheus, statsd). The router can be configured to provide HAProxy CSV format metrics, or provide no router metrics at all.
The metrics are collected from both the router controller and from HAProxy every five seconds. The router metrics counters start at zero when the router is deployed and increase over time. The HAProxy metrics counters are reset to zero every time haproxy is reloaded. The router collects HAProxy statistics for each frontend, back end, and server. To reduce resource usage when there are more than 500 servers, the back ends are reported instead of the servers because a back end can have multiple servers.
The statistics are a subset of the available HAProxy statistics.
The following HAProxy metrics are collected on a periodic basis and converted to Prometheus format. For every front end the “F” counters are collected. When the counters are collected for each back end and the “S” server counters are collected for each server. Otherwise, the “B” counters are collected for each back end and no server counters are collected.
See router environment variables for more information.
In the following table:
Column 1 - Index from HAProxy CSV statistics
Column 2
F | Front end metrics |
b | Back end metrics when not showing Server metrics due to the Server Threshold, |
B | Back end metrics when showing Server metrics |
S | Server metrics. |
Column 3 - The counter
Column 4 - Counter description
Index | Usage | Counter | Description |
2 | bBS | current_queue | Current number of queued requests not assigned to any server. |
4 | FbS | current_sessions | Current number of active sessions. |
5 | FbS | max_sessions | Maximum observed number of active sessions. |
7 | FbBS | connections_total | Total number of connections. |
8 | FbS | bytes_in_total | Current total of incoming bytes. |
9 | FbS | bytes_out_total | Current total of outgoing bytes. |
13 | bS | connection_errors_total | Total of connection errors. |
14 | bS | response_errors_total | Total of response errors. |
17 | bBS | up | Current health status of the back end (1 = UP, 0 = DOWN). |
21 | S | check_failures_total | Total number of failed health checks. |
24 | S | downtime_seconds_total | Total downtime in seconds.”, nil), |
33 | FbS | current_session_rate | Current number of sessions per second over last elapsed second. |
35 | FbS | max_session_rate | Maximum observed number of sessions per second. |
40 | FbS | http_responses_total | Total of HTTP responses, code 2xx |
43 | FbS | http_responses_total | Total of HTTP responses, code 5xx |
60 | bS | http_average_response_latency_milliseconds | of the last 1024 requests in milliseconds. |
The router controller scrapes the following items. These are only available with Prometheus format metrics.
Name | Description |
template_router_reload_seconds | Measures the time spent reloading the router in seconds. |
template_router_write_config_seconds | Measures the time spent writing out the router configuration to disk in seconds. |
haproxy_exporter_up | Was the last scrape of haproxy successful. |
haproxy_exporter_csv_parse_failures | Number of errors while parsing CSV. |
haproxy_exporter_scrape_interval | The time in seconds before another scrape is allowed, proportional to size of data. |
haproxy_exporter_server_threshold | Number of servers tracked and the current threshold value. |
haproxy_exporter_total_scrapes | Current total HAProxy scrapes. |
http_request_duration_microseconds | The HTTP request latencies in microseconds. |
http_request_size_bytes | The HTTP request sizes in bytes. |
http_response_size_bytes | The HTTP response sizes in bytes. |
openshift_build_info | A metric with a constant ‘1’ value labeled by major, minor, git commit & git version from which OpenShift was built. |
ssh_tunnel_open_count | Counter of SSH tunnel total open attempts |
ssh_tunnel_open_fail_count | Counter of SSH tunnel failed open attempts |