A router is one way to get traffic into the cluster. The HAProxy Template Router plug-in is one of the available router plugins.
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.5.18.
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
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:
Implementing sticky sessions is up to the underlying router configuration. The
default HAProxy template implements sticky sessions using the
directive, which balances based on the source IP. In addition, the template
router plug-in provides the service name and namespace to the underlying
implementation. This can be used for more advanced configuration, such as
implementing stick-tables that synchronize between a set of peers.
Specific configuration for this router implementation is stored in the /var/lib/haproxy/conf/haproxy-config.template file of the router container.