-
Notifications
You must be signed in to change notification settings - Fork 78
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
MAJOR: service discovery: Add support for Nomad #267
base: master
Are you sure you want to change the base?
Conversation
To test this locally, the easiest way is to run a local nomad agent (instructions here: https://gist.github.com/mr-karan/b1bb4f65ae31d91985e6a64451b79f6e) This config file can be used to connect dataplane to Nomad: service_discovery {
nomads = [
{
Address = "http://127.0.0.1"
Description = "Nomad test system"
Enabled = true
ID = "b40eb63b-2fb2-4996-b870-20f50ca173de"
Name = "my-nomad-service"
Namespace = "*"
Port = 4646
RetryTimeout = 15
SecretID = ""
ServerSlotsBase = 10
ServerSlotsGrowthIncrement = 10
ServerSlotsGrowthType = "linear"
},
]
} A sample Nomad job can be run using job "doggo" {
datacenters = ["dc1"]
type = "service"
namespace = "doggo"
group "app" {
count = 2
network {
port "http" {
to = 8080
}
}
task "web" {
driver = "docker"
service {
provider = "nomad"
name = "doggo-web"
tags = ["doggo", "web"]
port = "http"
}
config {
image = "ghcr.io/mr-karan/doggo-api:latest"
ports = ["http"]
}
resources {
cpu = 200
memory = 200
}
}
}
} When
This is how the HAProxy file looks:
|
Hi @mr-karan, thank you for the PR and sorry for delay, I will review this and get back to you. |
I have a just small comment, can you split the fix to the go-generate stuff into a separate commit to have a cleaner commit history? |
@mjuraga Done! |
Hi, just a small comment, can we have |
@mjuraga fixed :) |
@mjuraga Hey, just checking in if there are any blockers for this to get merged 😅 |
Hi @mr-karan, sorry for the delay again, we are currently preparing 2.7 version of the dataplaneapi, and we haven't had the chance to properly test this. Saying that we don't want to merge something like this (a new feature) so close to the release without proper testing. On the other side, by just looking at this it looks fine, and will probably get merged right after the release once we have a deeper look and test this. |
Sure thing, understandable. Thanks for letting me know! |
Thank you for the patience, I will come back to this as soon as possible, and let you know. |
@mjuraga Hi! Possible to share an update here? ^_^ |
Hi @mr-karan sorry for the too long delay, we've been busy with the latest release. I think your PR is OK, but we had to remove all usages of hashicorp libraries, like this here: https://github.com/haproxytech/dataplaneapi/pull/267/files#diff-01f037ab922981e5205173ea883804d526580df1e51a7ac2e45028dd20d1dc27 Unfortunately there is a licensing conflict between our project and their license so we needed to remove it. We can still consider your PR, but we would need to remove this import here. For example, you can check how we achieved that for consul service discovery support here: 4ad3136 Would you still be willing to work on this PR? |
@mjuraga Noted. Yeah that makes sense! I'll add this to my backlog for now but eager to contribute! 😅 |
Adds support for service discovery via Nomad services.
Nomad recently launched support for registering services for the tasks it's running. It's possible to retrieve the list of services using HTTP API with the Go SDK that it provides. In functionality terms it is very similar to Consul SDK.
The models for Nomad are generated in
client-native
and I've sent a PR for it: haproxytech/client-native#90Also fixes an issue with
go-generate
as discussed here: #266