'Access kubernetes control plane via hostname in /etc/hosts on all nodes

I want to create a small 4 to 6 nodes bare metal cluster with 2 control planes. The special idea is to give the control plane endpoint a special hostname (for instance "currentcontrolplane") which I want to map manually in the /etc/hosts file on each node host:

/etc/hosts (on each node)  
192.168.1.1    currentcontrolplane

kubeadm init --pod-network-cidr=10.244.0.0/16 --control-plane-endpoint **currentcontrolplane** --upload-certs

If I want to change the IP address in each /etc/hosts file to the second control plane after the cluster is still initialized the cluster is not working anymore - also not after reboot all nodes. Change it back - it works.

Does anyone know the reason why?



Solution 1:[1]

Meanwhile I've found the solution - oh no, so simple.

There must be a minimum of 3 control-planes for a HA cluster or if one master is down there must be at least a minimum of 2 control-planes. If there is at least only 1 master up, the whole cluster is down.

Anywhere I've found also a better solution for a bare metal cluster without load balancer.

"keepalived"

https://kvaps.medium.com/creating-high-available-baremetal-kubernetes-cluster-with-kubeadm-and-keepalived-simplest-guide-71766d5e25ae

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ffetech