Load balancing with HAPROXY & CONFD

Имеем:

$ fleetctl list-units
UNIT				MACHINE				ACTIVE	SUB
[email protected]	3408f7ab.../172.17.8.103	active	running
[email protected]	b2ca4512.../172.17.8.101	active	running
[email protected]		3408f7ab.../172.17.8.103	active	running
[email protected]		b2ca4512.../172.17.8.101	active	running
[email protected]		3408f7ab.../172.17.8.103	active	running
[email protected]		db577263.../172.17.8.102	active	running
[email protected]		b2ca4512.../172.17.8.101	active	running
[email protected]			3408f7ab.../172.17.8.103	active	running
[email protected]			db577263.../172.17.8.102	active	running
[email protected]			b2ca4512.../172.17.8.101	active	running


Я заменил оригинальные image, своими. Они отличаются только IP адресом. С оригинальным у меня не заработало.


$ vi haproxy.service


[Unit]
Description=haproxy Proxy

Requires=docker.service
After=docker.service
After=etcd2.service
Requires=etcd2.service

[Service]
EnvironmentFile=/etc/environment
User=core

Restart=always
TimeoutStartSec=0
ExecStartPre=-/usr/bin/docker kill %p-%i
ExecStartPre=-/usr/bin/docker rm %p-%i
ExecStartPre=-/usr/bin/etcdctl mkdir /services/todo
ExecStartPre=-/usr/bin/docker pull marley/coreos-haproxy
ExecStart=/usr/bin/docker run --name %p-%i \
      -h %H \
      -p ${COREOS_PUBLIC_IP}:80:80 \
      marley/coreos-haproxy
ExecStop=-/usr/bin/docker kill %p-%i
ExecStop=-/usr/bin/docker rm %p-%i

[X-Fleet]
Global=true


$ fleetctl submit haproxy.service
$ fleetctl start haproxy.service


$ fleetctl list-units
UNIT				MACHINE				ACTIVE	SUB
haproxy.service			3408f7ab.../172.17.8.103	active	running
haproxy.service			b2ca4512.../172.17.8.101	active	running
haproxy.service			db577263.../172.17.8.102	active	running
[email protected]	3408f7ab.../172.17.8.103	active	running
[email protected]	b2ca4512.../172.17.8.101	active	running
[email protected]		3408f7ab.../172.17.8.103	active	running
[email protected]		b2ca4512.../172.17.8.101	active	running
[email protected]		3408f7ab.../172.17.8.103	active	running
[email protected]		db577263.../172.17.8.102	active	running
[email protected]		b2ca4512.../172.17.8.101	active	running
[email protected]			3408f7ab.../172.17.8.103	active	running
[email protected]			db577263.../172.17.8.102	active	running
[email protected]			b2ca4512.../172.17.8.101	active	running


$ journalctl -f --lines=50 -u haproxy


http://172.17.8.101/
http://172.17.8.102/
http://172.17.8.103/

Все работает!

Если нужно остановить и выгрузить все, что касается сервиса:

$ fleetctl stop haproxy.service
$ fleetctl unload haproxy.service
$ fleetctl destroy haproxy.service