Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Paramoshka
Copy link
Contributor

@Paramoshka Paramoshka commented Jan 29, 2025

1. Why is this pull request needed and what does it do?

This pull request introduces a new CoreDNS plugin, dynamicforward, designed for dynamic tracking of Kubernetes Services and seamless updates to the forward server list. The plugin monitors EndpointSlices associated with a specified Service, dynamically adjusting the DNS forwarding configuration as endpoints are added, removed, or updated.

The dynamicforward plugin is particularly useful for organizing node-local-dns caching mechanism. In standard scheme we use ClusterIP as upstream, so we are delegating responsibility for load balancing to CNI. In case of apiserver failure, CNI don't know which upstream endpoints are alive or not.
But coredns itself can handle upstream healthchecks and in case of apiserver failure it will still keep the endpoints list and will load balance the requests.

There are some design imperfections:

  • The plugin don't support the full list of classic forward options. It uses the forward plugin for serving DNS under the hood, but it don't have public interface for configuring options.
  • Controversial name of the plugin.

2. Which issues (if any) are related?

3. Which documentation changes (if any) need to be made?

Added man.

4. Does this introduce a backward incompatible change or deprecation?

No.

Choose a reason for hiding this comment

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

There isn't guarantee the ServeDNS will be called after df.forwarder will be initialized and the mutex won't help. Need another solution.

Signed-off-by: Paramoshka <[email protected]>
Signed-off-by: Beastlex <[email protected]>
Signed-off-by: Andrey Polovov <[email protected]>
Co-authored-by: Beastlex <[email protected]>
Co-authored-by: Andrey Polovov <[email protected]>
@Paramoshka Paramoshka force-pushed the dynamicforward-plugin branch from 8c9f509 to df0a446 Compare January 31, 2025 09:24
@johnbelamaric
Copy link
Member

I haven't really looked at the code, but a few organizational points:

  1. The idea here is bypass kube-proxy load balancing and directly read the upstream service endpoint slices? I guess that reduces latency a little bit, does it really make that much difference?
  2. A name like kubeforward is probably better - it relies on kube existing, it's not independent of kube.
  3. Since it's really just for node-local-dns, why is this not part of https://github.com/kubernetes/dns/tree/master/cmd/node-cache ? I don't think it makes sense in upstream CoreDNS.

@apolovov
Copy link

Thank you, @johnbelamaric, for your feedback. Let me answer your questions:

  1. The idea here is bypass kube-proxy load balancing and directly read the upstream service endpoint slices? I guess that reduces latency a little bit, does it really make that much difference?

The main purpose of the plugin is not to reduce latency by eliminating an extra "hop," but to increase reliability.
Current scheme with the standard forward plugin in the event of an apiserver failure:

  • The kube-proxy will not handle kube-dns pod outages and will not exclude them from load balancing.
  • Consequently, coredns will continue sending requests to non-functioning upstream servers, leading to application issues.

Scheme with the new plugin:

  • Coredns will keep a list of upstream servers at the time of the apiserver failure.
  • It will perform its own health_checks and exclude any failed upstream servers.
  1. A name like kubeforward is probably better - it relies on kube existing, it's not independent of kube.

Good name, it is better, will rename if there won't be better options.

  1. Since it's really just for node-local-dns, why is this not part of https://github.com/kubernetes/dns/tree/master/cmd/node-cache ? I don't think it makes sense in upstream CoreDNS.

This tool uses coredns and it's Corefile under the hood, so here we are. Also, this tool is handy when you use some classic CNI with kube-proxy as Service implementation, but in clusters with eBPF-powered kube-proxy implementations (i.e. Cilium), it is overhead.

@chrisohaver
Copy link
Member

I think this should be an external plugin that node local dns can pull in.

@Paramoshka
Copy link
Contributor Author

Thank you @chrisohaver for the idea, I think this is a good option for our plugin to make it external. We will look at the documentation soon and redo the current PR. Is there no objection if we add an interface function SetProxyOptions to pass parameters to the forward plugin?
For the moment we accept the name kubeforward for our plugin, if there are other suggestions we will gladly consider them. Thanks for your comments!

@Paramoshka
Copy link
Contributor Author

Hello, @chrisohaver and @johnbelamaric,

Following the suggestions above, we have decided to move our dynamicforward - now under a new name kubeforward - to the external plugins In addition, we identified the need for an interface for passing parameters to the forward plugin. We implemented a separate PR for this purpose.

Thank you for your recommendations and feedback!

@thevilledev
Copy link
Collaborator

Hey @Paramoshka, shall we close the PR now that kubeforward is handled as an external plugin?

@Paramoshka
Copy link
Contributor Author

shall we close the PR now that kubeforward is handled as an external plugin?

@thevilledev Yeah, I think we can close, thanks for the reminder.

@Paramoshka Paramoshka closed this May 29, 2025
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

Successfully merging this pull request may close these issues.

6 participants