Welcome! Log In Create A New Profile

Advanced

HAProxy as a frontend for Docker Swarm deployment

Posted by Norman Branitsky 
Norman Branitsky
HAProxy as a frontend for Docker Swarm deployment
November 06, 2017 08:10PM
I just found out another group has started deploying microservice based apps on Docker Swarm
using Traefikhttps://docs.traefik.io/ saying:

"we are starting to deploy applications designed as microservices , but have chosen Traefik for our ability
to dynamically add sites based on Docker Service label."

Having read the docs, it appears to be reasonable for internal exposure only.
With respect to dynamic configuration based on Docker Service label,
how does this compare vis a vis HAProxy?

Norman

Norman Branitsky
Cloud Architect
MicroPact
(o) 416.916.1752
(c) 416.843.0670
(t) 1-888-232-0224 x61752
www.micropact.comhttp://www.micropact.com/
Think it > Track it > Done
Soluti Quintiliano
Re: HAProxy as a frontend for Docker Swarm deployment
November 06, 2017 08:20PM
I don't know how this would be done to Docker Swarm, but we are using
HAproxy in front of Kubernetes cluster with automatic HAproxy configuration
for each new services which need external access.

We just wrote an listener to the Kubernetes API whom update HAProxy as
needed. We choose to change HAproxy and reload it when changes occurs but
you can also write directly to its sockets for include/exclude backends.

Att.

Quintiliano.


2017-11-06 16:59 GMT-02:00 Norman Branitsky <[email protected]>
:

> I just found out another group has started deploying microservice based
> apps on Docker Swarm
>
> using Traefik https://docs.traefik.io/ saying:
>
>
> “we are starting to deploy applications designed as microservices , but
> have chosen Traefik for our ability
> to dynamically add sites based on Docker Service label.”
>
>
>
> Having read the docs, it appears to be reasonable for internal exposure
> only.
> With respect to dynamic configuration based on Docker Service label,
>
> how does this compare vis a vis HAProxy?
>
>
>
> Norman
>
>
>
>
> *Norman Branitsky *Cloud Architect
>
> MicroPact
>
> (o) 416.916.1752 <(416)%20916-1752>
>
> (c) 416.843.0670 <(416)%20843-0670>
>
> (t) 1-888-232-0224 x61752 <(888)%20232-0224>
>
> www.micropact.com
>
> Think it > Track it > Done
>
Norman Branitsky
RE: HAProxy as a frontend for Docker Swarm deployment
November 06, 2017 08:20PM
I believe Docker Swarm has a similar API.
Is the code for you listener public?

From: Soluti Quintiliano [mailto:[email protected]]
Sent: November-06-17 2:08 PM
To: Norman Branitsky <[email protected]>
Cc: haproxy@formilux.org
Subject: Re: HAProxy as a frontend for Docker Swarm deployment

I don't know how this would be done to Docker Swarm, but we are using HAproxy in front of Kubernetes cluster with automatic HAproxy configuration for each new services which need external access.

We just wrote an listener to the Kubernetes API whom update HAProxy as needed. We choose to change HAproxy and reload it when changes occurs but you can also write directly to its sockets for include/exclude backends.
Att.

Quintiliano.


2017-11-06 16:59 GMT-02:00 Norman Branitsky <[email protected]<mailto:[email protected]>>:
I just found out another group has started deploying microservice based apps on Docker Swarm
using Traefikhttps://docs.traefik.io/ saying:

“we are starting to deploy applications designed as microservices , but have chosen Traefik for our ability
to dynamically add sites based on Docker Service label.”

Having read the docs, it appears to be reasonable for internal exposure only.
With respect to dynamic configuration based on Docker Service label,
how does this compare vis a vis HAProxy?

Norman

Norman Branitsky
Cloud Architect
MicroPact
(o) 416.916.1752<tel:(416)%20916-1752>
(c) 416.843.0670<tel:(416)%20843-0670>
(t) 1-888-232-0224 x61752<tel:(888)%20232-0224>
www.micropact.comhttp://www.micropact.com/
Think it > Track it > Done
Soluti Quintiliano
Re: HAProxy as a frontend for Docker Swarm deployment
November 06, 2017 08:20PM
Sure. It still need some work but you can grasp the idea here:

https://github.com/QuintilianoB/kubernetes_haproxy

Hope it helps.

PS: I forgot about the translation. I'll do it latter and update it....

Att.



2017-11-06 17:11 GMT-02:00 Norman Branitsky <[email protected]>
:

> I believe Docker Swarm has a similar API.
> Is the code for you listener public?
>
>
>
> *From:* Soluti Quintiliano [mailto:[email protected]]
> *Sent:* November-06-17 2:08 PM
> *To:* Norman Branitsky <[email protected]>
> *Cc:* haproxy@formilux.org
> *Subject:* Re: HAProxy as a frontend for Docker Swarm deployment
>
>
>
> I don't know how this would be done to Docker Swarm, but we are using
> HAproxy in front of Kubernetes cluster with automatic HAproxy configuration
> for each new services which need external access.
>
> We just wrote an listener to the Kubernetes API whom update HAProxy as
> needed. We choose to change HAproxy and reload it when changes occurs but
> you can also write directly to its sockets for include/exclude backends.
>
> Att.
>
>
>
> Quintiliano.
>
>
>
>
>
> 2017-11-06 16:59 GMT-02:00 Norman Branitsky <[email protected]
> com>:
>
> I just found out another group has started deploying microservice based
> apps on Docker Swarm
>
> using Traefik https://docs.traefik.io/ saying:
>
>
> “we are starting to deploy applications designed as microservices , but
> have chosen Traefik for our ability
> to dynamically add sites based on Docker Service label.”
>
>
>
> Having read the docs, it appears to be reasonable for internal exposure
> only.
> With respect to dynamic configuration based on Docker Service label,
>
> how does this compare vis a vis HAProxy?
>
>
>
> Norman
>
>
>
>
> *Norman Branitsky *Cloud Architect
>
> MicroPact
>
> (o) 416.916.1752 <(416)%20916-1752>
>
> (c) 416.843.0670 <(416)%20843-0670>
>
> (t) 1-888-232-0224 x61752 <(888)%20232-0224>
>
> www.micropact.com
>
> Think it > Track it > Done
>
>
>
Baptiste
Re: HAProxy as a frontend for Docker Swarm deployment
November 06, 2017 09:50PM
On Mon, Nov 6, 2017 at 7:59 PM, Norman Branitsky <
[email protected]> wrote:

> I just found out another group has started deploying microservice based
> apps on Docker Swarm
>
> using Traefik https://docs.traefik.io/ saying:
>
>
> “we are starting to deploy applications designed as microservices , but
> have chosen Traefik for our ability
> to dynamically add sites based on Docker Service label.”
>
>
>
> Having read the docs, it appears to be reasonable for internal exposure
> only.
> With respect to dynamic configuration based on Docker Service label,
>
> how does this compare vis a vis HAProxy?
>
>
>
>
>
Hi,

As mentioned by Soluti, you need a "controller" whose main tasks will be:
- watch the orchestrator (or registry)
- generates the configuration accordingly to changes in the orchestrator
(or registry)
- applies the configuration changes (some of them can be applied at run
time, some of them will require a reload)

You can have a look to this project too:
https://github.com/jcmoraisjr/haproxy-ingress
It applies to Kubenetes and embeds some logic to apply changes at runtime
whenever possible.


Now, about Swarm itself, it's a bit messy... First, I'll speak about Swarm
mode only (because the other one seems deprecated).
You need to monitor events for "services" changes. From there, you need to
get the "task list" for each service, so it will give you the list of IPs
where the application is available.
All your application(s) server(s) must run in an overlay network, where
HAProxy has a "leg" too (otherwise HAProxy won't be able to reach the IPs
above). I let you imagine the nightmare from a design point of view...
Last, you have to do the http routing. Nothing is provided by Swarm mode
yet for this purpose. So you must use labels, as traefik has designed it.

Baptiste
Sorry, only registered users may post in this forum.

Click here to login