Skip to content

Conversation

@shwetha-s-poojary
Copy link

Switching load balancing from HAProxy to Envoy.
Based on the discussion in the referenced Slack thread: https://kubernetes.slack.com/archives/CEKK1KTN2/p1759769331878379.

@k8s-ci-robot k8s-ci-robot requested a review from aojea December 8, 2025 08:45
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: shwetha-s-poojary
Once this PR has been reviewed and has the lgtm label, please assign stmcginnis for approval. For more information see the Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot
Copy link
Contributor

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Dec 8, 2025
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 {
Copy link
Contributor

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

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.

Copy link
Author

@shwetha-s-poojary shwetha-s-poojary Dec 9, 2025

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.

Copy link
Contributor

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

https://github.com/kubernetes-sigs/cloud-provider-kind/blob/dc1a6e4c3b21716be9f87476d5cdb78389f05537/pkg/loadbalancer/server.go#L247-L263

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

Copy link
Member

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.

Copy link
Contributor

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

  1. bootstrap the container with an initial config that allow to use dynamic configuration based on files

unfortunately I think this is per provider https://github.com/search?q=repo%3Akubernetes-sigs%2Fkind%20runArgsForLoadBalancer&type=code

  1. at runtime, add the expected configuration

create the config as in cloudprovider kind

https://github.com/kubernetes-sigs/cloud-provider-kind/blob/4820e03979d5ff7fbcd8645794db2ff39a608b3f/pkg/loadbalancer/proxy.go#L82-L273

and write it to the corresponding node in the expected path (configured in step 1)

// 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")
}

Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants