From 1f44f83627d6710f54a479ad898335ee906ebd8f Mon Sep 17 00:00:00 2001 From: Roberto Bonafiglia Date: Fri, 16 Feb 2024 16:52:41 +0100 Subject: [PATCH] Adjust first node-ip based on configured clusterCIDR Signed-off-by: Roberto Bonafiglia --- pkg/agent/config/config.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/agent/config/config.go b/pkg/agent/config/config.go index e55fb71c06..d01c221b3c 100644 --- a/pkg/agent/config/config.go +++ b/pkg/agent/config/config.go @@ -447,6 +447,14 @@ func get(ctx context.Context, envInfo *cmds.Agent, proxy proxy.Proxy) (*config.N } } + if controlConfig.ClusterIPRange != nil { + if utilsnet.IPFamilyOfCIDR(controlConfig.ClusterIPRange) != utilsnet.IPFamilyOf(nodeIPs[0]) && len(nodeIPs) > 1 { + firstNodeIP := nodeIPs[0] + nodeIPs[0] = nodeIPs[1] + nodeIPs[1] = firstNodeIP + } + } + nodeExternalIPs, err := util.ParseStringSliceToIPs(envInfo.NodeExternalIP) if err != nil { return nil, fmt.Errorf("invalid node-external-ip: %w", err)