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

autodetect global addresses on loopback interfaces #95790

Merged
merged 2 commits into from Dec 9, 2020

Conversation

aojea
Copy link
Member

@aojea aojea commented Oct 22, 2020

What type of PR is this?

/kind bug
/kind feature

What this PR does / why we need it:

There are some network scenarios that, in order to have high availability based
on routing protocols, you may have multiple interfaces in the host and you use
a routing protocol to configure the routing.
It is common to not use global addresses on those interfaces because you don't want
them to be reachable, so you assign the global address to the loopback interface.

Loopback interfaces are always up, regardless of the states of physical interfaces.
They are not subject to interface problems, i.e., if the interface is down or flapping
you can not reach the IP despite you have connectivity through another interface.

We should consider global ip addresses on loopback interfaces when:

  • the host has default routes
  • there are no global IPs on those interfaces.

There can be more cases in which you have global addresses on the interfaces too,
but that will open an explosion of scenarios hard to support and to "autodetect"
It will be a cluster admin responsibility to configure the network in such
scenarios.

Which issue(s) this PR fixes:

Fixes #95779

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

The apimachinery util/net function used to detect the bind address `ResolveBindAddress()` takes into consideration global IP addresses on loopback interfaces when 1) the host has default routes, or 2) there are no global IPs on those interfaces in order to support more complex network scenarios like BGP Unnumbered RFC 5549

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Oct 22, 2020
@k8s-ci-robot
Copy link
Contributor

@aojea: This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Oct 22, 2020
@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Oct 22, 2020
@aojea
Copy link
Member Author

aojea commented Oct 22, 2020

/assign @thockin @liggitt

There are some network scenarios that, in order to have high availability based
on routing protocols, you may have multiple interfaces in the host and you use
a routing protocol to configure the routing in the host.
It is common to not use global addresses on those interfaces because you don't want
them to be reachable, so you assign the global address to the loopback interface.

Loopback interfaces are always up, regardless of the states of physical interfaces.
They are not subject to interface problems, i.e., if the interface is down or flapping
you can not reach the IP despite you have connectivity through another interface.

We should consider global ip addresses on loopback interfaces when:
- the host has default routes
- there are no global IPs on those interfaces.

There can be more cases in which you have global addresses on the interfaces too,
but that will open an explosion of scenarios hard to support and to "autodetect"
It will be a cluster admin responsability to configure the network in such
scenarios.
@liggitt
Copy link
Member

liggitt commented Oct 22, 2020

I don't have the networking context to know if this change makes sense. Can you clarify the following:

  • would this change behavior for callers that are currently succeeding, or only for callers that currently fail?
  • does this change the function to make it possible to return loopback interfaces where that was not previously possible? do all callers expect this?

@neolit123
Copy link
Member

i think we should reword the release note to exclude code details and only leave the user facing part for affected components e.g.:

kube-apiserver/kubeadm: for detection of bind-addresses take into consideration global IP addresses on loopback interfaces when:
    - the host has default routes
    - there are no global IPs on those interfaces.
in order to support more complex network scenarios like BGP Unnumbered RFC 5549

@aojea
Copy link
Member Author

aojea commented Oct 22, 2020

  • would this change behavior for callers that are currently succeeding, or only for callers that currently fail?

for current callers that are succeeding there is no change, I've also added unit test to verify that we don't break that

  • does this change the function to make it possible to return loopback interfaces where that was not previously possible? do all callers expect this?

the goal of ResolveBindAddress is to find an address that you can use to bind, and that address has to be reachable, it uses chooseHostInterfaceFromRoute to detect that IP. The heuristic is, if I have a route through one interface and that interface has a global IP address, this is the one that I want to use. This is a typical scenario in a cloud environment, the host is a VM with one interface and one IP assigned to that interface.

In more complex scenarios that does not have the advantage of one IaaS taking care of the underlay network of the host, like in baremetal, you use to have more than one interface connected to different switches, to provide redundancy.

There are different ways to provide redundancy with multiple interfaces, but that opens a lot of scenarios and I don't think that we must support any of them, but from all of those there is one that we can be sure that the the global address in the loopback interface is the right one to return unequivocally:

  • the host has a default route (presumably, it means it is not an isolated host and has connectivity)
  • the interfaces does not have global addresses and the loopback has (that means that it has to be configured that way by someone, loopback interfaces by default don't have global addresses)

Comment on lines +602 to +605
{"interface and loopback with global, IPv6", routeV6, globalsNetworkInterface{}, preferIPv6, net.ParseIP("fd00::200")},
{"interface and loopback with global, dual stack prefer IPv4", bothRoutes, globalsNetworkInterface{}, preferIPv4, net.ParseIP("192.168.1.1")},
{"interface and loopback with global, dual stack prefer IPv6", bothRoutes, globalsNetworkInterface{}, preferIPv6, net.ParseIP("fd00::200")},
{"interface and loopback with global, no routes", noRoutes, globalsNetworkInterface{}, preferIPv6, nil},
Copy link
Member Author

Choose a reason for hiding this comment

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

@liggitt these are the tests that verify that we don't modify previous behaviour, 192.168.1.1 and fd00::200 are the ones assigned to the interfaces and we check that take precedence over the ones assigned to the loopback interfaces

@fedebongio
Copy link
Contributor

/sig network
/cc @bowei @deads2k

@k8s-ci-robot k8s-ci-robot added the sig/network Categorizes an issue or PR as relevant to SIG Network. label Oct 22, 2020
@aojea
Copy link
Member Author

aojea commented Oct 22, 2020

/retest

// In case of network setups where default routes are present, but network
// interfaces use only link-local addresses (e.g. as described in RFC5549).
// the global IP is assigned to the loopback interface
loopbackIP, err := getIPFromInterface(LoopbackInterfaceName, family, nw)
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to make a similar check for loopback addresses in chooseIPFromHostInterfaces? Currently it also skips the loopback interface:

if isLoopbackOrPointToPoint(&intf) {
klog.V(4).Infof("Skipping: LB or P2P interface %q", intf.Name)
continue
}

Copy link
Member

Choose a reason for hiding this comment

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

Ah I see now -- this is only relevant when there's a default route and chooseIPFromHostInterfaces is not called unless there are no default routes anyways.

@roycaihw
Copy link
Member

SIG apimachinery passed this again and still wait for SIG network feedback.

@aojea
Copy link
Member Author

aojea commented Oct 29, 2020

/retest
/assign @thockin

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 14, 2020
@aojea
Copy link
Member Author

aojea commented Nov 14, 2020

/retest

@thockin
Copy link
Member

thockin commented Nov 16, 2020

Thanks!

/lgtm
/approve

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aojea, thockin

The full list of commands accepted by this bot can be found here.

The pull request process is described 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 approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 16, 2020
@aojea
Copy link
Member Author

aojea commented Nov 17, 2020

do we want this in 1.20 @thockin ?

@leilajal
Copy link
Contributor

/remove-sig api-machinery

@k8s-ci-robot k8s-ci-robot removed the sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. label Nov 17, 2020
@aojea
Copy link
Member Author

aojea commented Nov 22, 2020

Let's address next version, too late in this cycle for this change IMHO
/milestone 1.21

@k8s-ci-robot
Copy link
Contributor

@aojea: You must be a member of the kubernetes/milestone-maintainers GitHub team to set the milestone. If you believe you should be able to issue the /milestone command, please contact your and have them propose you as an additional delegate for this responsibility.

In response to this:

Let's address next version, too late in this cycle for this change IMHO
/milestone 1.21

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/test-infra repository.

@andrewsykim
Copy link
Member

/milestone 1.21

@k8s-ci-robot
Copy link
Contributor

@andrewsykim: The provided milestone is not valid for this repository. Milestones in this repository: [next-candidate, v1.16, v1.17, v1.18, v1.19, v1.20, v1.21, v1.22]

Use /milestone clear to clear the milestone.

In response to this:

/milestone 1.21

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/test-infra repository.

@andrewsykim
Copy link
Member

/milestone v1.21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/network Categorizes an issue or PR as relevant to SIG Network. 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.

BGP Unnumbered RFC 5549 ResolveBindAddress fails
9 participants