From f23d5b7c0ad575ec75f028eff4c33c8bb0e8b6e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20T=C3=B6lle?= Date: Mon, 22 Apr 2024 13:49:30 +0200 Subject: [PATCH] [v1.30] fix(hetzner): hostname label is not considered The Node Group info we currently return does not include the `kubernetes.io/hostname` label, which is usually set on every node. This causes issues when the user has an unscheduled pod with a `topologySpreadConstraint` on `topologyKey: kubernetes.io/hostname`. cluster-autoscaler is unable to fulfill this constraint and does not scale up any of the node groups. Related to #6715 --- .../cloudprovider/hetzner/hetzner_node_group.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cluster-autoscaler/cloudprovider/hetzner/hetzner_node_group.go b/cluster-autoscaler/cloudprovider/hetzner/hetzner_node_group.go index e6cf8b61b2bf..b010dfbadc3e 100644 --- a/cluster-autoscaler/cloudprovider/hetzner/hetzner_node_group.go +++ b/cluster-autoscaler/cloudprovider/hetzner/hetzner_node_group.go @@ -19,13 +19,12 @@ package hetzner import ( "context" "fmt" + "maps" "math/rand" "strings" "sync" "time" - "maps" - apiv1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -229,10 +228,14 @@ func (n *hetznerNodeGroup) TemplateNodeInfo() (*schedulerframework.NodeInfo, err return nil, fmt.Errorf("failed to create resource list for node group %s error: %v", n.id, err) } + nodeName := newNodeName(n) + node := apiv1.Node{ ObjectMeta: metav1.ObjectMeta{ - Name: newNodeName(n), - Labels: map[string]string{}, + Name: nodeName, + Labels: map[string]string{ + apiv1.LabelHostname: nodeName, + }, }, Status: apiv1.NodeStatus{ Capacity: resourceList,