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

feat: allow pod IPs even for non-hostNetwork pods #3174

Closed

Conversation

peterhoneder
Copy link

@peterhoneder peterhoneder commented Nov 21, 2022

but only for the internalHostnameAnnotationKey which doesn't use the node's IP anyway

Description

Pod IPs and node IPs can be used for hostname annotations on pods.

The existing implementation worked this way:

  • check if the pod has nodeNetwork: true
  • if no -> skip
  • otherwise:
    • for the internal hostname annotation -> use the pod' IP
    • for the regular hostname annotation -> use the node's IP
    • special handling for kops-dns-controller

I would like to change the implementation to cover a case, where Pod IPs can be exposed as names, but with pods where hostNetwork == false. This is a typical use case with CNI plugins like Calico CNI, where pod IPs are exposed as BGP routes directly to the ToR router/switch. So there is basically no service in front of the pod and the pod is directly exposed to the outside world of the cluster, most commonly with an internet-routable public IP, but could also be a private IP that is justed routed internally. The usefulness of this change addresses both those cases.

Since the pod's IP is already used for the internal hostname annotation, there is no need to actually limit this behavor to pods with nodeNetwork: true.

I can add public documentation for this, since the whole pod annotation part is not publicly documented yet, it might be a topic for a separate PR though.

There is no github issue for this yet.

Checklist

  • Unit tests updated
  • End user documentation updated

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Nov 21, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Nov 21, 2022
@k8s-ci-robot
Copy link
Contributor

Welcome @peterhoneder!

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 k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 21, 2022
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Nov 21, 2022
@johngmyers
Copy link
Contributor

johngmyers commented Nov 29, 2022

It looks like external-dns is, in emulating kOps dns-controller, is assuming the pod IP is the same as a singular internal node IP. The dns.alpha.kubernetes.io/internal annotation on a pod causes dns-controller to register the host-network pod with each of its node's internal IP addresses. This can be subtly different.

Both the node's internal IPs case and pod's IP case are useful. In some networking configurations, non-host pods' internal IPs are inaccessible, yet the node internal IPs are. There is also a difference for dual-stack nodes supporting a cluster with a single-stack pod network.

@peterhoneder
Copy link
Author

kOps dns-controller

the proposed PR currently does not change that behavior, but yes the existing implementation of the non kops compatible code path would only use NodeIPs from host network pods

@johngmyers
Copy link
Contributor

johngmyers commented Dec 2, 2022

I have a vague recollection of pods created in the early minutes of a new cluster having odd IP addresses, but I can't find anything like that in e2e tests. In the tests I've looked over, podIPs of host-network pods are consistently the internal IPs of the node. So there might not be a distinction after all.

Whether or not non-host-network pods are included can be controlled by whether non-host-network pods have the annotation.

There's a good question of whether it should use podIP or podIPs, but that's for after external-dns supports AAAA records.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 2, 2022
@johngmyers
Copy link
Contributor

johngmyers commented Dec 2, 2022

I think I remember what it was: before the CNI comes up, the podIP field might not get populated. So if your CNI depends on external-dns registering the kube-apiserver pods with DNS, you need external-dns to grab the IPs from the pod's node.

As previously noted, this was broken before and remains broken after the PR. The fix would be to follow from the pod to the node for pods that are host-networking. Fixing external-dns to correctly implement kOps requirements is behind #2051.

@peterhoneder
Copy link
Author

Hi!

my change does not affect the behavior for host-networking. It only allows an additional behavior for non host-networking pods, where the PodIP is correctly populated, and must be used instead of the host IP. The typical use case would be with a CNI like calico, where e.g. publicly routable IPv4 addresses are assigned to the pod.

@johngmyers
Copy link
Contributor

To be clear, I was not asking this PR to fix the handling of kOps requirements. It does not make things worse.

@peterhoneder
Copy link
Author

To be clear, I was not asking this PR to fix the handling of kOps requirements. It does not make things worse.

ok, thanks, perfect 😄 just wanted to make sure we have the same understanding 👍

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 6, 2023
@peterhoneder
Copy link
Author

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 6, 2023
@@ -254,7 +254,7 @@ func TestPodSource(t *testing.T) {
"",
[]*endpoint.Endpoint{
{DNSName: "a.foo.example.org", Targets: endpoint.Targets{"54.10.11.1"}, RecordType: endpoint.RecordTypeA},
{DNSName: "internal.a.foo.example.org", Targets: endpoint.Targets{"10.0.1.1"}, RecordType: endpoint.RecordTypeA},
{DNSName: "internal.a.foo.example.org", Targets: endpoint.Targets{"10.0.1.1", "100.0.1.2"}, RecordType: endpoint.RecordTypeA},
Copy link
Contributor

@szuecs szuecs May 2, 2023

Choose a reason for hiding this comment

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

The test name seems to be wrong.

And I wonder if you can increase test cases.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 11, 2023
@johngmyers johngmyers mentioned this pull request Jun 7, 2023
2 tasks
@johngmyers johngmyers mentioned this pull request Sep 13, 2023
2 tasks
@mloiseleur
Copy link
Contributor

@peterhoneder Do you think you can rebase this PR and takes into account review comment from @szuecs ?

@peterhoneder
Copy link
Author

@peterhoneder Do you think you can rebase this PR and takes into account review comment from @szuecs ?

yes, I will do that

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 21, 2023
@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 23, 2024
@didlawowo
Copy link

any news ?

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

New changes are detected. LGTM label has been removed.

@raoulbhatia
Copy link

FYI We have rebased the current patch on behalf of @peterhoneder onto latest master to ensure we are up2date

@thecmdradama
Copy link

Hi guys, any progress on getting this PR merged in? @mloiseleur

@raoulbhatia
Copy link

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 15, 2024
@foyerunix
Copy link
Contributor

Hello,

It seem I duplicated a great part of your effort in my own PR that also handle the reverse PTR creation: #4782

Perhaps there is a way to merge the two into something that could be accepted ?

Best Regards.

@peterhoneder
Copy link
Author

Hello,

It seem I duplicated a great part of your effort in my own PR that also handle the reverse PTR creation: #4782

Perhaps there is a way to merge the two into something that could be accepted ?

Best Regards.

I would be happy to see both of the PRs merged, especially since we use this PR already for a long time in production.

@szuecs
Copy link
Contributor

szuecs commented Jan 5, 2025

As long as it's only enabled for a certain new feature flag, I will not block this pr. Same for the other mentioned one.

In general I don't think it is a good idea but I will not block IMO broken architectures (don't try to explain why it is not broken 😉). Some are likely not in control of these assumptions and cannot easily change them.

Happy new year everyone, hope we can get this through the line for you.

@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 ask for approval from mloiseleur. 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 k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. and removed cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 7, 2025
but only for the internalHostnameAnnotationKey which doesn't use the node's IP anyway
tests validate this for annotations with:
- mixing pods in the host network with others that are not
- multiple comma separated annotations per Pod
- explicitly set targets
- IPv4 and IPv6
- incorporated changes from PR kubernetes-sigs#3468 to allow for arbitrary annotations
  to be used no matter the hostNetwork property's value
- updated docs to make clear how the annotations are used for pods
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jan 7, 2025
@mloiseleur
Copy link
Contributor

@peterhoneder Do that work for you ? It seems to me that since #4782 already implements it behind a feature flag, we should focus on this one. Anything I missed ?

@peterhoneder
Copy link
Author

@peterhoneder Do that work for you ? It seems to me that since #4782 already implements it behind a feature flag, we should focus on this one. Anything I missed ?

I'm not completely sure why this would need a feature flag, since you specifically have to add the annotation to enable the PodIP to be used anyway? Seems like a double opt-in then for me. Could you explain?

@foyerunix
Copy link
Contributor

foyerunix commented Jan 13, 2025

Hello @peterhoneder,

I believe my PR also accommodates your use case. As I understand it, using --ignore-non-host-network-pods without my second new option --pod-source-domain should achieve the desired results.

Do you see any improvements we could make to better handle your use case?

Best regards.

@raoulbhatia
Copy link

@foyerunix et al – we implemented our requirement based on #4782 with --no-ignore-non-host-network-pods.
We are still in in a verification/monitoring mode, but overall things look good at this point.

We will keep an eye on our deployment.
If everything is well, we can close this PR in favor of #4782 next week.

Thanks @foyerunix for pushing this :-)

@mloiseleur
Copy link
Contributor

@peterhoneder Now that #4782 has been merged, I understand that we can close this one. Feel free to re-open it if I missed something.
/close

@k8s-ci-robot
Copy link
Contributor

@mloiseleur: Closed this PR.

In response to this:

@peterhoneder Now that #4782 has been merged, I understand that we can close this one. Feel free to re-open it if I missed something.
/close

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 Feb 15, 2025
@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.

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-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.