This is a cache of https://docs.openshift.com/container-platform/3.5/architecture/core_concepts/haproxy-router.html. It is a snapshot of the page at 2024-11-21T03:52:18.034+0000.
<strong>haproxy</strong> Router Plug-in - Core Concepts | Architecture | OpenShift Container Platform 3.5
×

Overview

A router is one way to get traffic into the cluster. The haproxy Template Router plug-in is one of the available router plugins.

haproxy Template Router

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 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:

HAProxy Router Data Flow
Figure 1. haproxy Router Data Flow

Sticky Sessions

Implementing sticky sessions is up to the underlying router configuration. The default haproxy template implements sticky sessions using the balance source 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.

The balance source directive does not distinguish between external client IP addresses; because of the NAT configuration, the originating IP address (haproxy remote) is the same. Unless the haproxy router is running with hostNetwork: true, all external clients are routed to a single pod.