MicroK8s failed to join RPI cluster error code 500

I had this issue myself using rpi4b 4GB and ubuntu server 20.04. After a bit of playing around I got it to work by setting the hostname to be identical to what is in each /etc/hosts entry, for example:

/etc/hosts
192.168.2.100 rpi-1.cluster
192.168.2.100 rpi-2.cluster
192.168.2.100 rpi-3.cluster

on each rpi used:
sudo hostnamectl set-hostname rpi-x.cluster

rebooted… redid addnode/join combo and it all worked!!

Hope this helps

note also, if you reboot the hostname will revert, unless you modified :
/etc/cloud/cloud.cfg
preserve_hostname: true

i’ve solved this problem.

according to microk8s join --worker | connection failed refusing to join · Issue #2967 · canonical/microk8s · GitHub
You need to make sure that your master node can also resolve your worker node to its IP address.

what I’ve done:
add all the IP addresses and server’s name of the nodes in ur cluster under /etc/hosts of master node:
10.32.234.105 master #IP address and server’s name of the master node
10.32.234.106 worker1 #IP address and server’s name of the worker node
10.32.234.107 worker2

then
add this under /etc/hosts of each worker node
10.32.234.106 worker1 #IP address and server’s name of the worker node

after this, again run the $ microk8s add-node, and build a Kubernetes cluster, u’ll find it solved.