Skip to content

Commit 603b71f

Browse files
committed
Metal uses a different label for the hostname
1 parent 28eb1a3 commit 603b71f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

internal/controller/node_controller.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ import (
4343
const (
4444
EVICTION_REQUIRED_LABEL = "cloud.sap/hypervisor-eviction-required"
4545
EVICTION_APPROVED_LABEL = "cloud.sap/hypervisor-eviction-succeeded"
46-
HOST_LABEL = "kubernetes.metal.cloud.sap/host"
46+
HOST_LABEL = "kubernetes.metal.cloud.sap/host" // metal3
47+
NAME_LABEL = "kubernetes.metal.cloud.sap/name" // metal
4748
)
4849

4950
type NodeReconciler struct {
@@ -119,8 +120,13 @@ func (r *NodeReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.
119120
// kubernetes.metal.cloud.sap/role: kvm (rather set these in gardener, as it is fixed)
120121
// kubernetes.metal.cloud.sap/bb
121122
// kubernetes.metal.cloud.sap/host
123+
// kubernetes.metal.cloud.sap/name
122124
// kubernetes.metal.cloud.sap/node-ip
123125
func (r *NodeReconciler) normalizeName(ctx context.Context, node *corev1.Node) (string, bool, error) {
126+
if name, found := node.Labels[NAME_LABEL]; found {
127+
return name, false, nil
128+
}
129+
124130
if host, found := node.Labels[HOST_LABEL]; found {
125131
return host, false, nil
126132
}
@@ -171,6 +177,7 @@ func (r *NodeReconciler) normalizeName(ctx context.Context, node *corev1.Node) (
171177
func (r *NodeReconciler) setHostLabel(ctx context.Context, node *corev1.Node, host string) bool {
172178
changed, err := r.setNodeLabels(ctx, node, map[string]string{
173179
HOST_LABEL: host,
180+
NAME_LABEL: host,
174181
})
175182
if err != nil {
176183
log := logger.FromContext(ctx)

0 commit comments

Comments
 (0)