-
Notifications
You must be signed in to change notification settings - Fork 13
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
Allow specifying GRPC load balancer #5
base: master
Are you sure you want to change the base?
Conversation
@pieterlouw Any thoughts on this? |
Ho @d4l3k , Few things: How does this affect the Caddyfile setup? Can you perhaps post an example? The only thing that bothers me is the gRPC Naming package is still experimental according to the documentation. I'm sure it's stable, it's just I'm reluctant to add an API that might change and break future Caddy builds. |
Hey, This shouldn't change the Caddyfile setup at all. It just checks for a GRPC SRV record first. and falls back to just normal DNS resolution. And yeah, I totally missed the fact that that package was experimental and deprecated. I'll investigate a bit more and update the PR. |
Okay, I just took a deeper look into this. Looks like load balancing is actually supported out of the box, but the default resolver is "passthrough" and load balancer is "pick_first". For SRV resolving you can just do |
I updated this PR to add a As for the balancing stuff being experimental, this code no longer depends on any package other than the main This in use would look like
|
case "balancer": | ||
if !c.Args(&s.balancerName) { | ||
return c.Errf("balancer missing argument") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this make "balancer" a required field in the Caddyfile?
"balancer" should be optional, especially important for backward compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe this makes it required. It just means if you specify balancer
you need to provide an argument.
Thanks @d4l3k I added a comment on the changes you made in setup.go (https://github.com/pieterlouw/caddy-grpc/pull/5/files#diff-4d86aab957c347ca87f7021d57b17205) |
This is the easiest way I can see of adding in load balancing. I don't think there should be an unexpected side effects but please let me know if you can think of anything.
This adds in a round robin DNSResolver for load balancing purposes. The GRPC DNSResolver first checks if SRV records are present on the specified host and if so, uses them. If they don't exist it just resolves the DNS hostname as normal. If there's an IP specified it just uses that.