-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Adopt Envoy in place of HAProxy for load balancing #4064
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
base: main
Are you sure you want to change the base?
Adopt Envoy in place of HAProxy for load balancing #4064
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: shwetha-s-poojary The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Hi @shwetha-s-poojary. Thanks for your PR. I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
| if err := loadBalancerNode.Command("kill", "-s", "HUP", "1").Run(); err != nil { | ||
| return errors.Wrap(err, "failed to reload loadbalancer") | ||
| // restart loadbalancer to apply static configuration changes | ||
| if err := exec.Command("docker", "restart", "kind-external-load-balancer").Run(); err != nil { |
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.
Others, please correct me if I am wrong, but I don't believe we want to explicitly call docker commands here. User may be using podman or nerdctl and not have docker present on their system. Is there an equivalent to sending HUP to envoy?
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.
you do not need to restart , see how is done in cloud provider kind https://github.com/kubernetes-sigs/cloud-provider-kind/blob/4820e03979d5ff7fbcd8645794db2ff39a608b3f/pkg/loadbalancer/proxy.go#L276-L313
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.
Yeah, we should not exec directly to docker in particular here, but we also don't need to.
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.
@stmcginnis envoy does support hot restarts, but for this scenario a simple container restart seems to be the most reliable and straightforward option. I’ll look into detecting the container runtime so we can use the appropriate tool instead of assuming docker.
@aojea @BenTheElder from my understanding, only dynamic (xDS) configuration avoids restarts; static configuration still requires one. For the kind use case, static config seems sufficient and avoids the complexity of a full dynamic config setup. The cloud-provider-kind example you shared above uses dynamic config, but I believe the earlier version relied on static config and required restarts (ref: PR link).
Please correct me if I’m mistaken anywhere — I appreciate the guidance.
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.
@shwetha-s-poojary if we know all the configuration before hand you just need to pass the final config during the entrypoint and you can just use existing libraries to create the container, see
the example I provided in my previous comment is to update the configuration dynamically without having to restart the container, you can write files on the filesystem of the container and envoy will pick the config and autoconfigure itself, no need to restarts
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’ll look into detecting the container runtime so we can use the appropriate tool instead of assuming docker.
I'd really rather not expand the node container runtime abstraction just for this purpose, haproxy has been working ~fine.
But see antonio's comment above.
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.
@shwetha-s-poojary so you need to follow the cloud-provider-kind implementation, a straw man approach will be
- bootstrap the container with an initial config that allow to use dynamic configuration based on files
-
example config
https://github.com/kubernetes-sigs/cloud-provider-kind/blob/4820e03979d5ff7fbcd8645794db2ff39a608b3f/pkg/loadbalancer/proxy.go#L33-L53 -
override the config during container start https://github.com/kubernetes-sigs/cloud-provider-kind/blob/37c196059f9c31de6f0734e22b608923f00eb195/pkg/loadbalancer/server.go#L247-L257
unfortunately I think this is per provider https://github.com/search?q=repo%3Akubernetes-sigs%2Fkind%20runArgsForLoadBalancer&type=code
- at runtime, add the expected configuration
create the config as in cloudprovider kind
and write it to the corresponding node in the expected path (configured in step 1)
kind/pkg/cluster/internal/create/actions/loadbalancer/loadbalancer.go
Lines 77 to 91 in 02382a0
| // create loadbalancer config data | |
| loadbalancerConfig, err := loadbalancer.Config(&loadbalancer.ConfigData{ | |
| ControlPlanePort: common.APIServerInternalPort, | |
| BackendServers: backendServers, | |
| IPv6: ctx.Config.Networking.IPFamily == config.IPv6Family, | |
| }) | |
| if err != nil { | |
| return errors.Wrap(err, "failed to generate loadbalancer config data") | |
| } | |
| // create loadbalancer config on the node | |
| if err := nodeutils.WriteFile(loadBalancerNode, loadbalancer.ConfigPath, loadbalancerConfig); err != nil { | |
| // TODO: logging here | |
| return errors.Wrap(err, "failed to copy loadbalancer config to node") | |
| } |
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.
@aojea @BenTheElder @stmcginnis Thanks for the guidance! Looks like switching to dynamic config is the way to go.I'll get on it.
Switching load balancing from HAProxy to Envoy.
Based on the discussion in the referenced Slack thread: https://kubernetes.slack.com/archives/CEKK1KTN2/p1759769331878379.