instantlinux/haproxy-keepalived

By instantlinux

Updated 10 days ago

A load balancer with haproxy and keepalived for VRRP to provide high-availability services.

Image
Networking
3

50K+

instantlinux/haproxy-keepalived repository overview

haproxy-keepalived

A load balancer with haproxy and keepalived (VRRP) to provide high-availability networking.

Usage

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
Variables

These variables can be passed to the image from kubernetes.yaml or docker-compose.yml as needed:

VariableDefaultDescription
KEEPALIVE_CONFIG_IDmainWhich configuration to use (usually a hostname)
PORT_HAPROXY_STATS8080What port to use for stats page
STATS_ENABLEyesWhether to include stats
STATS_SECRETNAMEhaproxy-stats-passwordSecret to use for stats page
STATS_USERhaproxyUsername for stats page basic-auth
STATS_URI/statsURI for stats page
TIMEOUT50000Timeout for haproxy (ms)
TZUTCtime zone for syslog
Secrets
SecretDescription
haproxy-stats-passwordpassword for haproxy user in stats page
Contributing

If you want to make improvements to this image, see CONTRIBUTING.

Tag summary

Content type

Image

Digest

sha256:4774603fe

Size

19.7 MB

Last updated

10 days ago

docker pull instantlinux/haproxy-keepalived