The haproxy-reload-wrapper watches the HAProxy configuration file using an inotify watcher and, if a change is detected, performs a hitless reload by transferring listening sockets from the old HAProxy process to the new, reloaded process. If the new HAProxy process fails to start or the changed configuration is invalid, the old process continues to operate to avoid any interruptions. More details about the reload mechanism in HAProxy can be found in the following blog post: Truly Seamless Reloads with HAProxy – No More Hacks!.
Features
Tracking changes in the configuration file and triggering seamless reloads of the HAProxy
Graceful signal (termination) handling and transparent management of HAProxy processes
Support for configuration files from mounted ConfigMap
How to use
Configure a socket with the expose-fd listeners option in the haproxy.cfg file:
global
stats socket /var/run/haproxy.sock mode 600 level admin expose-fd listeners
Set the HAPROXY_SOCKET environment variable to the path of the socket if it is different from the default path: /var/run/haproxy.sock.
Optionally set the WATCH_PATH environment variable to watch a directory instead of the haproxy.cfg file only
Replace the docker.io/haproxy image with the ghcr.io/snorwin/haproxy image on container platforms or compile the source code and run ./haproxy-reload-wrapper on a Linux system. As an example, check out the Helm chart used for the tests.
Modify the configuration file and let the magic happen.✨