Repository: kube-vip/kube-vip (2026-04-06T14:50:14Z)

Issue:
Node names should be rfc1123 compliant even when falling back on os.Hostname()
**Describe the bug**
It is possible to have hostnames for machines contain uppercase characters; even if you keep the hostname for the node name it will be lower cased for rfc1123. 

This causes service node label updates to fail as the node does not exist with that name in k8s.

While this configuration is legacy it also seems reasonable to accommodate as this is a known case.

**To Reproduce**
Deploy k8s with upper case host names and use kube-vip with labeling on nodes.

**Expected behavior**
When looking for a node it should give best effort and not intentionally just use a bad value.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Environment (please complete the following information):**
 - OS/Distro: [e.g. Ubuntu 1804]
 - Kubernetes Version: [e.g. v.1.18]
 - Kube-vip Version: [e.g. 0.2.3]

**`Kube-vip.yaml`:**
If Possible add in your kube-vip manifest (please remove anything that is confidential)

**Additional context**
Add any other context about the problem here.


Discussion:

Patch:
diff --git a/pkg/manager/manager.go b/pkg/manager/manager.go
index 2a20d696..f3a0fe0d 100644
--- a/pkg/manager/manager.go
+++ b/pkg/manager/manager.go
@@ -8,6 +8,7 @@ import (
 	"os"
 	"os/signal"
 	"path/filepath"
+	"strings"
 	"sync"
 	"sync/atomic"
 	"syscall"
@@ -104,6 +105,7 @@ func New(configMap string, config *kubevip.Config) (*Manager, error) {
 		}
 		config.NodeName = hostname
 	}
+	config.NodeName = normalizeNodeName(config.NodeName)
 	log.Info("using node name", "name", config.NodeName)
 
 	adminConfigPath := "/etc/kubernetes/admin.conf"
@@ -447,3 +449,9 @@ func (sm *Manager) Kill() {
 		sm.signalChan <- syscall.SIGINT
 	})
 }
+
+// normalizeNodeName ensures the local machine hostname conforms to
+// Kubernetes RFC1123 node naming conventions (lowercase).
+func normalizeNodeName(name string) string {
+	return strings.ToLower(name)
+}


Test patch:
diff --git a/pkg/manager/manager_test.go b/pkg/manager/manager_test.go
new file mode 100644
index 00000000..adabdca2
--- /dev/null
+++ b/pkg/manager/manager_test.go
@@ -0,0 +1,38 @@
+package manager
+
+import (
+	"testing"
+
+	"github.com/stretchr/testify/assert"
+)
+
+func TestNormalizeNodeName(t *testing.T) {
+	tests := []struct {
+		name     string
+		hostname string
+		expected string
+	}{
+		{
+			name:     "All lowercase hostname remains unchanged",
+			hostname: "worker-node-1",
+			expected: "worker-node-1",
+		},
+		{
+			name:     "Mixed case hostname is lowercased",
+			hostname: "Worker-Node-1",
+			expected: "worker-node-1",
+		},
+		{
+			name:     "All uppercase hostname is lowercased",
+			hostname: "MASTER-NODE",
+			expected: "master-node",
+		},
+	}
+
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			result := normalizeNodeName(tt.hostname)
+			assert.Equal(t, tt.expected, result, "The normalized node name did not match the expected RFC1123 compliant name")
+		})
+	}
+}