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 OpenShift Container Platform.

The HAProxy template file can be customized as
needed to support features that are not currently supported by OpenShift Container Platform.
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
5 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, backend and server. To reduce resource usage when there are more than
500 servers, the backends are reported instead of the servers since a backend
can have multiple servers.

The following HAProxy metrics are collected on a periodic basis and converted to
Prometheus format. For every frontend the "F" counters are collected. When the
counters are collected for each backend and the "S" server counters are
collected for each server. Otherwise, the "B" counters are collected for each
backend and no server counters are collected.