haproxy-keepalived
A load balancer with haproxy and keepalived for VRRP to provide high-availability services.
50K+
A load balancer with haproxy and keepalived (VRRP) to provide high-availability networking.
Configuration is defined as files in volumes mounted as /usr/local/etc/haproxy.d and /etc/keepalived/keepalived.conf.
Define your local settings for haproxy under /usr/local/etc/haproxy.d; see man page; the entrypoint script here will concatenate multiple files.
Define your keepalived settings in /etc/keepalived/keepalived.conf; see man page.
If you want to override the haproxy.cfg defined in this image, mount your own as /usr/local/etc/haproxy/haproxy.cfg with read-only set.
If you want to add vrrp_track_process directive in keepalived config, specify pid=host to docker (see example in docker-compose.yml)
See the haproxy-keepalived/examples/ directory under this git repository to get started.
This requires NET_ADMIN privileges: keepalived will run as root (but you can specify user haproxy or keepalived_script for the vrrp_script directive); haproxy will downgrade itself to user haproxy after startup. Also, you will need the ip_vs kernel module and ip_nonlocal set on the host running docker engine:
echo ip_vs >>/etc/modules.conf
echo net.ipv4.ip_nonlocal_bind=1 >/etc/sysctl.d/99-haproxy.conf
sysctl -p /etc/sysctl.d/99-haproxy.conf
After starting this service using helm, kubectl apply or docker-compose, you can connect to http://:/stats to view the haproxy stats page, with basic-auth username haproxy and the password set in the secret defined below. This repo has complete instructions for building a kubernetes cluster where you can deploy kubernetes.yaml using make and customizing Makefile.vars after cloning this repo:
git clone https://github.com/instantlinux/docker-tools.git
cd docker-tools/k8s
make haproxy-keepalived
These variables can be passed to the image from kubernetes.yaml or docker-compose.yml as needed:
| Variable | Default | Description |
|---|---|---|
| KEEPALIVE_CONFIG_ID | main | Which configuration to use (usually a hostname) |
| PORT_HAPROXY_STATS | 8080 | What port to use for stats page |
| STATS_ENABLE | yes | Whether to include stats |
| STATS_SECRETNAME | haproxy-stats-password | Secret to use for stats page |
| STATS_USER | haproxy | Username for stats page basic-auth |
| STATS_URI | /stats | URI for stats page |
| TIMEOUT | 50000 | Timeout for haproxy (ms) |
| TZ | UTC | time zone for syslog |
| Secret | Description |
|---|---|
| haproxy-stats-password | password for haproxy user in stats page |
If you want to make improvements to this image, see CONTRIBUTING.
Content type
Image
Digest
sha256:4774603fe…
Size
19.7 MB
Last updated
10 days ago
docker pull instantlinux/haproxy-keepalived