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

hubble: Add "hubble-prefer-ipv6" option #21751

Merged
merged 1 commit into from
Oct 26, 2022

Conversation

mKeRix
Copy link
Contributor

@mKeRix mKeRix commented Oct 17, 2022

Please ensure your pull request adheres to the following guidelines:

  • For first time contributors, read Submitting a pull request
  • All code is covered by unit and/or runtime tests where feasible.
  • All commits contain a well written commit description including a title,
    description and a Fixes: #XXX line if the commit addresses a particular
    GitHub issue.
  • If your commit description contains a Fixes: <commit-id> tag, then
    please add the commit author[s] as reviewer[s] to this issue.
  • All commits are signed off. See the section Developer’s Certificate of Origin
  • Provide a title or release-note blurb suitable for the release notes.
  • Thanks for contributing!

This change adds an option to the Hubble Relay communication that allows to configure the previously hardcoded IPv4/IPv6 preference. When a node has mixed IPv4 and IPv6 addresses, but internal cluster communication is only IPv6-based, Hubble would announce wrong node addresses which would break communication to the agents. The previous IPv4 preference is kept as default.

Our specific use case for this is EKS with IPv6. When an instance is put into a public subnet and receives a public IP, this IP will be mapped as ExternalIP onto the node. Hubble will then announce that IP, even though no communication can happen on it. Instead, it should announce the IPv6 address the EC2 instance (like it does for nodes without public IP).

We've tested this changeset successfully in real IPv6 EKS clusters using a custom build of v1.12.2.

hubble: Add "hubble-prefer-ipv6" option

@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Oct 17, 2022
@mKeRix mKeRix force-pushed the pr/hubble-ipv6-preference branch 3 times, most recently from a5af78d to 2765eda Compare October 17, 2022 12:53
@mKeRix mKeRix marked this pull request as ready for review October 17, 2022 14:10
@mKeRix mKeRix requested review from a team as code owners October 17, 2022 14:10
Copy link
Member

@kaworu kaworu left a comment

Choose a reason for hiding this comment

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

Thank you @mKeRix for the PR!

The --hubble-prefer-ipv6 flag is fine to me, but in code I would slightly prefer (no pun intended) to express the addr family preference like k8s apimachinery rather than bubbling down a bool (in other words, "parsing" the flag as a AddressFamilyPreference). That way nodeAddress would be easier to read IMHO, e.g.

func nodeAddress(n types.Node, pref AddressFamilyPreference) string {
    for _, family := range pref {
        switch family {
        case familyIPv4:
            if addr := n.GetNodeIP(false); addr.To4() != nil {
                return addr.String()
            }
        case familyIPv6:
            if addr := n.GetNodeIP(true); addr.To4() == nil {
                return addr.String()
            }
        }
    }
    return ""
}

pkg/hubble/peer/handler.go Outdated Show resolved Hide resolved
@kaworu kaworu requested a review from rolinh October 18, 2022 08:36
@kaworu kaworu added kind/feature This introduces new functionality. release-note/misc This PR makes changes that have no direct user impact. sig/hubble Impacts hubble server or relay labels Oct 18, 2022
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Oct 18, 2022
@mKeRix
Copy link
Contributor Author

mKeRix commented Oct 18, 2022

Hey @kaworu,

thanks for your remarks! I tried to integrate your proposals and pushed a new version. I was a bit insecure about where to put the AddressFamily types. I've now thrown them into the serviceoption package, but if you think there is a better place for them I'd appreciate a pointer.

@mKeRix mKeRix requested review from kaworu and removed request for jibi, rolinh and ldelossa October 18, 2022 15:57
Copy link
Member

@kaworu kaworu left a comment

Choose a reason for hiding this comment

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

Awesome @mKeRix thanks for the update, small nit but other than that the patch LGTM.

pkg/hubble/peer/serviceoption/option.go Outdated Show resolved Hide resolved
Copy link
Member

@rolinh rolinh left a comment

Choose a reason for hiding this comment

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

Looks solid, thanks!

Copy link
Member

@jibi jibi left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @mKeRix! I think we are missing the Helm chart changes to export this new option. It should be just a matter of adding a new value and then using it in the configmap template.

As an example you can have a look at how it's done for the Hubble listening address:

(and then remember to run make -C Documentation update-helm-values to update the docs)

@mKeRix mKeRix requested review from a team as code owners October 25, 2022 14:50
@mKeRix
Copy link
Contributor Author

mKeRix commented Oct 25, 2022

Thank you for the hint @jibi! I've adapted the PR accordingly.

@mKeRix mKeRix requested review from jibi and removed request for ldelossa and tommyp1ckles October 25, 2022 14:51
@mKeRix mKeRix force-pushed the pr/hubble-ipv6-preference branch 2 times, most recently from ac7e1db to bbbf998 Compare October 25, 2022 15:08
When a node has mixed IPv4 and IPv6 addresses, but internal cluster
communication is only IPv6-based, Hubble would announce wrong node
addresses which would break communication to the agents. This option
allows to control this behavior explicitly. The previous IPv4 preference
is kept as default.

Signed-off-by: Heiko Rothe <me@heikorothe.com>
@mKeRix mKeRix requested a review from a team as a code owner October 25, 2022 15:14
@mKeRix mKeRix requested a review from qmonnet October 25, 2022 15:14
@jibi
Copy link
Member

jibi commented Oct 25, 2022

/test

Copy link
Member

@qmonnet qmonnet left a comment

Choose a reason for hiding this comment

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

Looks good, thank you

@jibi
Copy link
Member

jibi commented Oct 26, 2022

/test-runtime

@jibi
Copy link
Member

jibi commented Oct 26, 2022

test-1.23-5.4 is failing due to #21735, ci-external-workloads is failing to provision the cluster (#21885 should fix it), all other required tests are green, marking as ready

@jibi jibi added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Oct 26, 2022
@nathanjsweet nathanjsweet merged commit 5905304 into cilium:master Oct 26, 2022
@mKeRix mKeRix deleted the pr/hubble-ipv6-preference branch October 28, 2022 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature This introduces new functionality. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/misc This PR makes changes that have no direct user impact. sig/hubble Impacts hubble server or relay
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants