From a752d1056d67fb261dd436f378f42a14ede56ca1 Mon Sep 17 00:00:00 2001 From: Serge Logvinov Date: Fri, 16 Feb 2024 14:40:29 +0200 Subject: [PATCH] feat: kubelet dualstack support Enable cloud Dual-Stack with --node-ip support since Kubernetes 1.29 release. Signed-off-by: Serge Logvinov --- pkg/proxmox/instances.go | 7 ++++++- pkg/proxmox/instances_test.go | 31 +++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/pkg/proxmox/instances.go b/pkg/proxmox/instances.go index 5385c29..6d2abd8 100644 --- a/pkg/proxmox/instances.go +++ b/pkg/proxmox/instances.go @@ -138,7 +138,12 @@ func (i *instances) InstanceMetadata(_ context.Context, node *v1.Node) (*cloudpr } } - addresses := []v1.NodeAddress{{Type: v1.NodeInternalIP, Address: providedIP}} + addresses := []v1.NodeAddress{} + + for _, ip := range strings.Split(providedIP, ",") { + addresses = append(addresses, v1.NodeAddress{Type: v1.NodeInternalIP, Address: ip}) + } + addresses = append(addresses, v1.NodeAddress{Type: v1.NodeHostName, Address: node.Name}) instanceType, err := i.getInstanceType(vmRef, region) diff --git a/pkg/proxmox/instances_test.go b/pkg/proxmox/instances_test.go index 784bc53..76a8e86 100644 --- a/pkg/proxmox/instances_test.go +++ b/pkg/proxmox/instances_test.go @@ -416,6 +416,37 @@ func (ts *ccmTestSuite) TestInstanceMetadata() { Zone: "pve-1", }, }, + { + msg: "NodeExistsDualstack", + node: &v1.Node{ + ObjectMeta: metav1.ObjectMeta{ + Name: "cluster-1-node-1", + Annotations: map[string]string{ + cloudproviderapi.AnnotationAlphaProvidedIPAddr: "1.2.3.4,2001::1", + }, + }, + }, + expected: &cloudprovider.InstanceMetadata{ + ProviderID: "proxmox://cluster-1/100", + NodeAddresses: []v1.NodeAddress{ + { + Type: v1.NodeInternalIP, + Address: "1.2.3.4", + }, + { + Type: v1.NodeInternalIP, + Address: "2001::1", + }, + { + Type: v1.NodeHostName, + Address: "cluster-1-node-1", + }, + }, + InstanceType: "4VCPU-10GB", + Region: "cluster-1", + Zone: "pve-1", + }, + }, { msg: "NodeExistsCluster2", node: &v1.Node{