Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to automate the creation of the frontend #1

Open
webmutation opened this issue Oct 28, 2021 · 7 comments
Open

Is there a way to automate the creation of the frontend #1

webmutation opened this issue Oct 28, 2021 · 7 comments

Comments

@webmutation
Copy link

Hello,

I am trying to expose the services automatically via HAProxy, I am using the Consul K8S sync mechanism.

Currently I am having a couple of problems:

  • All services get added to HAProxy config, I have not seen a way to filter them.
  • I have also not seen a way to automate the creation of the frontend config.

Any hints how to solve these issues?

@NickMRamirez
Copy link
Collaborator

Hi @webmutation You can use the Data Plane API to create a frontend programmatically. There's an example here:

https://www.haproxy.com/documentation/hapee/latest/configuration/config-sections/frontend/

As for filtering which services get added, you could add a feature request with the Data Plane API project:

https://github.com/haproxytech/dataplaneapi/issues

@webmutation
Copy link
Author

webmutation commented Nov 1, 2021

HI @NickMRamirez thanks for the information. I was hopping it would be possible to have some annotations via consul labels. Similar to what can be done with Fabio LB but i guess that use case is not supported.

Would really like to see how the integration is being done. Can you point me to the code used to support this Sync mechanism? I wonder how hard it would be to extend this mechanism.

I will try to see if I can create some expression to only filter the backends that we want to expose... that probably the simplest workaround to achieve routing via HAProxy of k8s backends.

@NickMRamirez
Copy link
Collaborator

I am only a user of the integration myself, and not an engineer on the project, but it looks like the code is here in the "discovery" folder: https://github.com/haproxytech/dataplaneapi/tree/master/discovery

@NickMRamirez
Copy link
Collaborator

@webmutation I see that in the latest release of the Data Plane API, they added: "the Consul Service Discovery now has the ability to filter services by namespace"

https://www.haproxy.com/blog/announcing-haproxy-data-plane-api-2-4/

@webmutation
Copy link
Author

It seems its a bit limited, it seems its the consul namespace that this refers to, not the cluster namespaces, at least when i tried to filter using

curl -u dataplaneapi:mypassword \
       -H 'Content-Type: application/json' \
       -d '{
             "address": "1.1.1.",
             "port": 80,
             "enabled": true,
	     "namespace": "dev",
             "retry_timeout": 10
           }' http://1.1.1.1:5555/v2/service_discovery/consul

even though I have a service deployed there

backend consul-backend-1.1.1.1-80-another-nginx-service-nodeport-dev

I did not get any services back... after i removed the namespace option it worked with all services. including the one mentioned above.

If I may abuse a bit more your goodwill, how are you managing the creation of the frontend section? Do you incorporate this in the CD stage? Its what I was thinking to have the service register the frontend section once it is deployed.

@NickMRamirez
Copy link
Collaborator

I asked our engineers about it, and it refers to the Consul namespace, which is a Consul Enterprise feature. You can then add all services that you want to proxy through HAProxy to have that one namespace.

@NickMRamirez
Copy link
Collaborator

I haven't got as far as automating the frontend creation. My use case was more of a proof of concept to learn the service discovery feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants