1 min read

Solved: Failed to configure agent: Node password rejected, duplicate hostname or contents RKE2/K3S

Solved: Failed to configure agent: Node password rejected, duplicate hostname or contents RKE2/K3S

If you recreate server with the same name that has been already joined in your cluster, you will end up with this error message.

WARN[0000] not running in CIS mode
INFO[0000] Starting rke2 agent v1.21.3+rke2r1 (2ed0b0d1b6924af4414393cd1796c174a1ff5352)
INFO[0000] Running load balancer 127.0.0.1:6444 -> [10.0.0.2:9345]
WARN[0000] Cluster CA certificate is not trusted by the host CA bundle, but the token does not include a CA hash. Use the full token from the server's node-token file to enable Cluster CA validation.
INFO[0000] Running load balancer 127.0.0.1:6443 -> [10.0.0.2:6443]
ERRO[0000] Failed to configure agent: Node password rejected, duplicate hostname or contents of '/etc/rancher/node/password' may not match server node-passwd entry, try enabling a unique node name with the --with-node-id flag

Problem is described here: Removing node doesn't remove node password · Issue #802 · k3s-io/k3s (github.com)

So do not remove node via kubectl delete node <nodeId> command and use official uninstall script.

Solution:

kubectl -n kube-system delete secrets <agent-node-name>.node-password.rke2 or kubectl -n kube-system delete secrets <agent-node-name>.node-password.k3s