K8s nodes load balancer service consul haproxy

Hi ! I ve tried three years ago to configure dynamically haproxy with consul. It worked pretty well.
Now i want to reproduce the external load balancer service we can find on public cloud but on bare metal.

For instance : say I have a k8s cluster with three bare metal compute nodes. I want to configure an external load balancer. I want it to be an external haproxy with a new service created in k8s. And i want, if I had a new node in the k8s, I want it to serve all the existing service within the existing haproxy.

I want to register nodes in haproxy by consul.
I want to create service on haproxy by consul on these registered nodes.

I don t know if it s clear. Consul changed a lot these last years. And for now, i don t know how to do it.

Can you explain me in a few words how i can achieve it ?

Hi @jy.cadic,

I think this will help you in understanding the current options of HAProxy + Consul integration better. Load Balancing with HAProxy Service Discovery Integration | Consul - HashiCorp Learn

Hi, thank uou for your answer. I already know this url. For i tried it many years ago if i remember.
And yes, i can have the dynamic information of a new node for example. Or a server that freeze, and so on.

But when i create a nex deployment on kube. With a new service, with an ingress on nodeport, i want consul to sync between this two informations :

The ip of the nodes it discovrered, and the nodeport the ingress created on k8s on each node, for the deployment.

It is how to mix the two informations that i m searching for.

If anyone have a clue ?

Just trying to understand your requirement better. Do you have a hard dependency on HAProxy? Consul Service Mesh already has an Ingress Gateway offering (which uses envoy proxy) which perfectly fits your requirement from my current understanding of your requirement.

Here is an example of how it is used Allow External Traffic Inside Your Service Mesh With Ingress Gateways | Consul - HashiCorp Learn

The above pattern is supported and well integrated on Consul on K8S as well.

How familiar are you with Consul Service Mesh, and specifically on K8S. I would encourage you to go through the Consul K8S QuickStart linked below.

The K8S deployments in Kubernetes is registered to Consul by adding annotations to the deployments. You can find more details by exploring he Consul Kubernetes Quick start guide Get Started on Kubernetes | Consul - HashiCorp Learn.

With all the above resources I think you will be able to come up with a solution for your requirement.

1 Like

Hi, thank you for your answer.
I think i’ll can manage to do what I want to do with the urls you gave me.
I used Traefik not so long ago, and, I wanted to try envoy anyway.
That a good way to start.

now that you gave me a direction, i have to walk the path.

again, thank you.

have a nice day