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

IPV6 APIVIP Handling #589

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

IPV6 APIVIP Handling #589

wants to merge 10 commits into from

Conversation

dbw7
Copy link
Contributor

@dbw7 dbw7 commented Oct 18, 2024

No description provided.

pkg/kubernetes/cluster.go Outdated Show resolved Hide resolved
pkg/kubernetes/cluster.go Outdated Show resolved Hide resolved
pkg/kubernetes/cluster.go Outdated Show resolved Hide resolved
pkg/combustion/templates/k8s-vip.yaml.tpl Outdated Show resolved Hide resolved
pkg/combustion/kubernetes_test.go Outdated Show resolved Hide resolved
pkg/image/validation/kubernetes.go Outdated Show resolved Hide resolved
pkg/image/validation/kubernetes.go Outdated Show resolved Hide resolved
pkg/image/validation/kubernetes.go Show resolved Hide resolved
@hardys
Copy link
Contributor

hardys commented Oct 21, 2024

Thanks for working on this @dbw7 - I recall @mchiappero was working on some similar changes in #513 so perhaps Marco can review to ensure those changes are also captured here

As a next step beyond this, I think we'll need to add dual-stack support too (particularly for the management cluster use-case because I think Rancher only supports dual-stack, not yet single-stack ipv6)

I guess that will require a couple of configuration changes:

  • Configure the k8s cluster networks for dual stack e.g https://docs.rke2.io/networking/basic_network_options#dual-stack-configuration
  • Configure the APIVIP to support two addresses (perhaps comma delimited like in the RKE2 config above), such that the k8s API is accessible via both address families - I think this will require adding another CIDR to the addresses in the MetalLB IPAddressPool

@atanasdinov
Copy link
Contributor

@hardys We'd indeed want to add dual-stack support - in fact, the first iteration of @dbw7 work was on it. I pushed back on it for now since it's safer (especially with changes to definition file) to do this in multiple steps where the first one is to enable the IPv6 support and have it thoroughly tested (in SV too) before proceeding with dual-stack.

pkg/image/validation/kubernetes.go Outdated Show resolved Hide resolved
pkg/image/validation/kubernetes.go Outdated Show resolved Hide resolved
pkg/image/validation/kubernetes.go Outdated Show resolved Hide resolved
pkg/kubernetes/cluster.go Outdated Show resolved Hide resolved
atanasdinov
atanasdinov previously approved these changes Oct 21, 2024
@atanasdinov atanasdinov requested a review from jdob October 21, 2024 13:26
jdob
jdob previously approved these changes Oct 21, 2024
RELEASE_NOTES.md Outdated
@@ -4,6 +4,8 @@

## General

* Added support for IPV6 addresses in the Kubernetes 'apiVIP' field
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Added support for IPV6 addresses in the Kubernetes 'apiVIP' field
* Added support for IPv6 addresses in the Kubernetes 'apiVIP' field

@@ -261,7 +261,7 @@ kubernetes:
* `network` - Required for multi-node clusters, optional for single-node clusters; Defines the network configuration
for bootstrapping a cluster.
* `apiVIP` - Required for multi-node clusters, optional for single-node clusters; Specifies the IP address which
will serve as the cluster LoadBalancer, backed by MetalLB.
will serve as the cluster LoadBalancer, backed by MetalLB. Supports IPV4 and IPV6 addresses.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
will serve as the cluster LoadBalancer, backed by MetalLB. Supports IPV4 and IPV6 addresses.
will serve as the cluster LoadBalancer, backed by MetalLB. Supports IPv4 and IPv6 addresses.

@@ -316,11 +317,18 @@ func (c *Combustion) downloadRKE2Artefacts(ctx *image.Context, cluster *kubernet
}

func kubernetesVIPManifest(k *image.Kubernetes) (string, error) {
ip, err := netip.ParseAddr(k.Network.APIVIP)
if err != nil {
return "", fmt.Errorf("parsing kubernetes APIVIP address: %w", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like this should read as apiVIP instead of all caps, since that's what the field is named in the definition. But I don't feel particularly strongly if you decide to keep it like this.

setMultiNodeConfigDefaults(kubernetes, serverConfig)
ip, err := netip.ParseAddr(kubernetes.Network.APIVIP)
if err != nil {
return nil, fmt.Errorf("parsing kubernetes APIVIP address: %w", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above. It's an error message and the user-friendly output shows apiVIP, so whatever you decide just be consistent between this and the previous message I commented on.

@dbw7 dbw7 dismissed stale reviews from jdob and atanasdinov via 79b8c83 October 21, 2024 14:36
@dbw7 dbw7 requested a review from jdob October 21, 2024 14:36
Error: err,
})
}
if !parsedIP.Is4() && !parsedIP.Is6() {
Copy link

@mchiappero mchiappero Oct 24, 2024

Choose a reason for hiding this comment

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

These two checks are redundant, when the address is parsed successfully it's either IPv4 or IPv6. And would also not pass the following IsGlobalUnicast() test anyway.

@@ -1084,192 +1079,90 @@ func TestValidateAdditionalArtifacts(t *testing.T) {
}
}

func TestValidateNodes(t *testing.T) {
func TestValidateNetwork(t *testing.T) {
Copy link

@mchiappero mchiappero Oct 24, 2024

Choose a reason for hiding this comment

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

Hey Danial, glad to see that most of my code has been reused :)
I saw you re-wrote and simplified this function, which on the one hand is good, but ends having a much smaller coverage. The one I wrote was carefully calibrated around the IsGlobalUnicast() check (and internal sub-checks), so that the different cases of non-global unicast values were sufficiently tested. I think it make sense to include a couple of additional malformed IPs (e.g. 500.168.1.1), but I'd bring back the cases from my initial work as it's just a matter of copying and pasting.

Copy link

@mchiappero mchiappero left a comment

Choose a reason for hiding this comment

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

I'm not sure if I'll have time today to continue my review (by the way, sorry for being late), but in the meantime please have a look at my couple of comments.

Edit: I don't have anything to add. Sorry for not doing a review in a one shot, I wasn't sure I'd have had time but didn't want to hold things until next week, in case. It looks good to me and can't wait to see it included, but I'd address the two main comments right now rather than later.

@@ -821,3 +821,46 @@ func TestConfigureKubernetes_SuccessfulRKE2ServerWithManifests(t *testing.T) {
assert.Contains(t, contents, "name: my-nginx")
assert.Contains(t, contents, "image: nginx:1.14.2")
}

func TestKubernetesVIPManifestValidIPV4(t *testing.T) {
Copy link

@mchiappero mchiappero Oct 24, 2024

Choose a reason for hiding this comment

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

Nit-picking, but I'd align these two names from "IPV4"/"IPV6" to IPv4 too, as the rest of the code/prints.

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.

5 participants