Moshe
Moshe

Reputation: 5139

Docker overlay with HAProxy

I have a QA environment in which I run all my applications and HAProxy on the same overlay network. I want HAProxy to be able to start without the servers being necessarily up so my server configuration is for example:

backend cirrus
    option      httpclose
    option      forwardfor
    balance     leastconn

    server cirrus01 cirrus-bos01:6021 check init-addr none

notice the init-addr none which allows me to disable initial dns resolution. Problem with this configuration is that all servers are marked as unhealthy and they never become healthy so I always get NOSRV:

2018-12-05T16:50:42+00:00localhost haproxy[12]: 192.168.10.118:64813 
[05/Dec/2018:16:50:42.981] main cirrus/<NOSRV>
0/-1/-1/-1/0 503 212 - - SC-- 1/1/0/0/0 0/0
{cirrus.docker-app.qa01.company.com|} "GET / HTTP/1.1"

even though the url cirrus-bos01 IS available from the container itself.

Now if I were to remove the check init-addr none from the server definition, haproxy would crash for services I haven't deployed yet:

[ALERT] 338/165450 (1) : parsing [/usr/local/etc/haproxy/haproxy.cfg:347] : 'server renderer' : could not resolve address 'ytuploader'.
[ALERT] 338/165450 (1) : Failed to initialize server(s) addr.

Because there really isn't a server named ytuploader yet.

Is there a docker/haproxy solution for this?

Upvotes: 1

Views: 1175

Answers (1)

Moshe
Moshe

Reputation: 5139

I found the solution! I changed the server definition from

server cirrus01 cirrus-bos01:6021 check init-addr none

to:

server cirrus01 cirrus-bos01:6021 check init-addr last,libc,none

Upvotes: 1

Related Questions