Skip to content
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

add ability to disable nodePort Support #4727

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

jpiper
Copy link

@jpiper jpiper commented Sep 5, 2024

Description

When running external-dns in a multi-tenant environment (e.g. in namespaced=true mode in the helm chart), users may not be in a position to give access to the Node resource to the external-dns deployment. At the moment, external-dns will not function without access to the Node resource as a Node informer is always created by the Pod and Service sources.

In this PR I add the flag --ignore-nodeports that disables the Node informer and then ensures the Pod and Service sources makes no attempt to try and retrieve any information from the Node resource.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign mloiseleur for approval. For more information see the Kubernetes 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 k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 5, 2024
@k8s-ci-robot k8s-ci-robot requested a review from szuecs September 5, 2024 13:55
@k8s-ci-robot
Copy link
Contributor

Welcome @jpiper!

It looks like this is your first PR to kubernetes-sigs/external-dns 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/external-dns has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @jpiper. Thanks for your PR.

I'm waiting for a kubernetes-sigs 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. labels Sep 5, 2024
@munnerz
Copy link
Member

munnerz commented Sep 5, 2024

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 5, 2024
Copy link
Contributor

@mloiseleur mloiseleur left a comment

Choose a reason for hiding this comment

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

Thanks, this PR looks good, is tested and documented 👍 .

As Albert Camus said:

To name things wrongly is to add to the misfortune of the world

If I understand correctly, when external-dns is namespaced, it does not make sense to set ignoreNodePorts to true.

So, 🤔 wdyt of renaming ignore-nodeports cli args into namespaced ?
And so, in the chart, when namespaced is enabled, it would add this --namespaced=true that would disable the informer ?

},
)
)
}
Copy link
Contributor

@szuecs szuecs Sep 18, 2024

Choose a reason for hiding this comment

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

should we warn here in else instead of in Endpoints() ?
I guess it's expected to not flood all day the logs.

Same applies to service

Copy link
Author

Choose a reason for hiding this comment

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

good point, I've dropped the log level in servive/pod to a debug level and then added warnings here.

@jpiper
Copy link
Author

jpiper commented Oct 4, 2024

Thanks, this PR looks good, is tested and documented 👍 .

As Albert Camus said:

To name things wrongly is to add to the misfortune of the world

If I understand correctly, when external-dns is namespaced, it does not make sense to set ignoreNodePorts to true.

So, 🤔 wdyt of renaming ignore-nodeports cli args into namespaced ? And so, in the chart, when namespaced is enabled, it would add this --namespaced=true that would disable the informer ?

It really depends, in an environment where you have access to the node resource, you could still run in the namespaced mode with the nodeinformer enabled, it really depends on your multi-tenancy model of your cluster. I have seen people give tenants access to the node resource, and likewise, multi-tenant clusters where you are not allowed to view the node resource. However, I agree, the naming could be improved. How do we feel about disableNodeSupport?, which then really implies that node hostnames/IPs will not be able to be synced?

@jpiper
Copy link
Author

jpiper commented Oct 4, 2024

alternatives I can think of for the flag:

--(disable|ignore)-node-(info|data|resources)
--disable-node-informer (leaks implementation details)

@mloiseleur

This comment was marked as resolved.

@jpiper
Copy link
Author

jpiper commented Oct 4, 2024

It really depends, in an environment where you have access to the node resource, you could still run in the namespaced mode with the nodeinformer enabled,

I am sorry: I do not understand this. When one is namespaced, AFAIK there is no Cluster RBAC. so there is no access possible to node, since it's a Cluster-wide resources.

Did I miss something ?

ah yes, this is my fault, sorry. I am getting confused between how the chart works and how one could theoretically deploy external-dns using a namespace scope but still using cluster resources. The chart doesn't support this deployment mode though so you're right, I can disable the node informer with the helm namespaced helm value is set to true

@@ -123,6 +125,11 @@ func legacyEndpointsFromDNSControllerService(svc *v1.Service, sc *serviceSource)
// It will use node role label to check if the node has the "node" role. This means control plane nodes and other
// roles will not be used as targets.
func legacyEndpointsFromDNSControllerNodePortService(svc *v1.Service, sc *serviceSource) ([]*endpoint.Endpoint, error) {
if sc.nodeInformer == nil {
log.Warnf("Unable to extract nodePort targets from service %s/%s as nodePort support is disabled", svc.Namespace, svc.Name)
Copy link

Choose a reason for hiding this comment

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

Since the user explicitly disabled nodePort support then Info seems more appropriate than Warn.

Suggested change
log.Warnf("Unable to extract nodePort targets from service %s/%s as nodePort support is disabled", svc.Namespace, svc.Name)
log.Infof("Unable to extract nodePort targets from service %s/%s as nodePort support is disabled", svc.Namespace, svc.Name)

I've suggested Info level here (and elsewhere Warn is used) but I see other places in the PR where Debug is used.

source/pod.go Outdated Show resolved Hide resolved
source/service.go Outdated Show resolved Hide resolved
@mloiseleur
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 27, 2024
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

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 the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 30, 2024
@mloiseleur
Copy link
Contributor

/assign @Raffo

@mloiseleur mloiseleur removed their assignment Dec 22, 2024
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. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that 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.

7 participants