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 dual-stack support on flannel #3906

Merged
merged 2 commits into from Sep 15, 2021
Merged

Conversation

manuelbuil
Copy link
Contributor

Signed-off-by: Manuel Buil mbuil@suse.com

Proposed Changes

Add the flannel part of the dual-stack support for k3s. First version

Types of Changes

New Feature

Verification

Deploy k3s with:

write-kubeconfig-mode: 644
token: "secret"
cluster-cidr: 10.42.0.0/16,2001:cafe:42:0::/56
service-cidr: 10.43.0.0/16,2001:cafe:42:1::/112
disable-network-policy: true

And having your main interface with an ipv6 address. Of course your infra must allow ipv6 traffic!

Linked Issues

#1405

User-Facing Change


Further Comments

@manuelbuil manuelbuil requested a review from a team as a code owner August 24, 2021 18:16
@codecov-commenter
Copy link

codecov-commenter commented Aug 24, 2021

Codecov Report

Merging #3906 (9fcd79b) into master (5e0fae9) will decrease coverage by 0.04%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3906      +/-   ##
==========================================
- Coverage   11.52%   11.47%   -0.05%     
==========================================
  Files         132      132              
  Lines        8928     8965      +37     
==========================================
  Hits         1029     1029              
- Misses       7673     7710      +37     
  Partials      226      226              
Flag Coverage Δ
inttests 0.69% <0.00%> (-0.01%) ⬇️
unittests 11.12% <0.00%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/agent/flannel/flannel.go 0.00% <0.00%> (ø)
pkg/agent/flannel/setup.go 0.00% <0.00%> (ø)
pkg/cli/server/server.go 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5e0fae9...9fcd79b. Read the comment docs.

pkg/agent/flannel/flannel.go Outdated Show resolved Hide resolved
pkg/agent/flannel/flannel.go Outdated Show resolved Hide resolved
pkg/agent/flannel/flannel.go Outdated Show resolved Hide resolved
pkg/agent/flannel/setup.go Outdated Show resolved Hide resolved
scripts/version.sh Outdated Show resolved Hide resolved
@manuelbuil manuelbuil force-pushed the dual-stack branch 4 times, most recently from 3cdd054 to b58701f Compare September 7, 2021 15:18
@manuelbuil manuelbuil force-pushed the dual-stack branch 2 times, most recently from f0ae37b to 1cdc1b7 Compare September 7, 2021 17:04
@manuelbuil manuelbuil changed the title [WIP] Add dual-stack support Add dual-stack support Sep 7, 2021
Copy link
Contributor

@vadorovsky vadorovsky left a comment

Choose a reason for hiding this comment

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

First remark - could you please make clear in the PR name that it's only about flannel? I.e. flannel: Add dual-stack support

The current title gives an impression that it's supposed to solve dual-stack in the whole k3s at once, which is not true (there is work in kube-router to be done).

@manuelbuil manuelbuil changed the title Add dual-stack support Add dual-stack support on flannel Sep 7, 2021
Copy link
Contributor

@vadorovsky vadorovsky left a comment

Choose a reason for hiding this comment

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

Just two nits lol I'm an idiot, I was commenting code from vendor/ 🤦

Copy link
Contributor

@vadorovsky vadorovsky left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

pkg/agent/flannel/flannel.go Outdated Show resolved Hide resolved
confJSON = strings.ReplaceAll(confJSON, "%DUALSTACK%", "true")
for _, cidr := range nodeConfig.AgentConfig.ClusterCIDRs {
if utilsnet.IsIPv6(cidr.IP) {
// Assuming there is going to be only one ipv6 range
Copy link
Contributor

Choose a reason for hiding this comment

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

Recent versions of Kubernetes allow you to specify multiple non-overlapping, non-contiguous ipv4/ipv6 ranges. Is it too much work to allow that? We should at least handle it properly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a good point Brad! I wanted to look at this but forgot to do it. I don't think flannel supports multiple ranges but I need to verify this. If it does not, I guess we should fail with an error describing this, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After some investigations and questions to sig-network guys, the conclusion is that multiple non-overlapping, non-contiguous ipv4/ipv6 ranges is not supported yet. It's under development kubernetes/enhancements#2593

Copy link
Contributor

@brandond brandond Sep 8, 2021

Choose a reason for hiding this comment

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

Interesting, I'll have to dig up the changelog entry I was thinking of. It's possible that one of the cloud providers has added support for this already but the core controller-manager nodeipam does not yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added the link in the comment, so that we don't forget this

Copy link
Contributor

Choose a reason for hiding this comment

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

Here's what I was thinking of - it appears that this is GKE only and hasn't hit core Kubernetes yet:
https://cloud.google.com/kubernetes-engine/docs/how-to/multi-pod-cidr

@manuelbuil manuelbuil changed the title Add dual-stack support on flannel [WIP] Add dual-stack support on flannel Sep 10, 2021
@manuelbuil
Copy link
Contributor Author

I'll add the tests in a different commit but same PR

@brandond
Copy link
Contributor

brandond commented Sep 14, 2021

Now that we have tests in, can we pull out the startup check for --flannel-backend=none when using dual-stack? I'm excited to land this!

@manuelbuil
Copy link
Contributor Author

Now that we have tests in, can we pull out the startup check for --flannel-backend=none when using dual-stack? I'm excited to land this!

Wait, we have unit tests. I'm working on integration tests. Hopefully done tomorrow

@manuelbuil manuelbuil force-pushed the dual-stack branch 3 times, most recently from 35f6618 to 262b397 Compare September 15, 2021 07:59
@manuelbuil manuelbuil changed the title [WIP] Add dual-stack support on flannel Add dual-stack support on flannel Sep 15, 2021
@manuelbuil manuelbuil force-pushed the dual-stack branch 2 times, most recently from 957aba6 to 702addf Compare September 15, 2021 09:04
Signed-off-by: Manuel Buil <mbuil@suse.com>
@@ -467,7 +467,7 @@ func validateNetworkConfiguration(serverConfig server.Config) error {
return errors.Wrap(err, "failed to validate cluster-dns")
}

if (serverConfig.ControlConfig.FlannelBackend != "none" || serverConfig.ControlConfig.DisableNPC == false) && (dualCluster || dualService) {
if (serverConfig.ControlConfig.DisableNPC == false) && (dualCluster || dualService) {
Copy link
Contributor

@brandond brandond Sep 15, 2021

Choose a reason for hiding this comment

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

Remove the flannel reference from the error message on the next line too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch!

…kend

Signed-off-by: Manuel Buil <mbuil@suse.com>
@manuelbuil
Copy link
Contributor Author

@dereknola could you check the tests please?

Copy link
Contributor

@dereknola dereknola left a comment

Choose a reason for hiding this comment

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

Tests look good

@manuelbuil manuelbuil merged commit 60cd86b into k3s-io:master Sep 15, 2021
@manuelbuil manuelbuil deleted the dual-stack branch October 28, 2021 08:19
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.

None yet

6 participants