'Unable to register exisiting K8s cluster to Rancher

I am running Rancher 2.6.2 with single-node K8s installation.

I am trying to register an exisitng K8s cluster to rancher but it does not show any thing after I click the button create. It just show:

enter image description here

I checked all the logs in all rancher pods but they did not show any valuable information.

Please help me with this.

Thank you so much. Viet



Solution 1:[1]

Same issue I got when I was trying to register k8s cluster via Rancher. I post my solution here to help someone in case:

In my situation, I got limited information like this question for my problem, then.

  1. We should check log first:

Go to the k8s cluster node (the one you exec the rancher node register command), docker ps -a list all running container; then use docker logs <container-id> to check all *-cattle-* related container and etcd.

Normally, a k8s joined to a rancher will have some necessary containers with status UP. For example, if you running a development environment with a 'docker version' rancher, it should be container named kubelet and kube-proxy etc. more detail can be found at https://rancher.com/docs/rancher/v2.6/en/troubleshooting/kubernetes-components/

If none of official troubleshooting can be used to solve your problem, then inspect the docker container with docker inspect <container-id> The rancher agent will run https://github.com/rancher/agent/blob/master/package/run.sh during the initialization. If the container exit unnormally, we should check it's configuration, e.g. compare CHECKSUM between your host's CA with rancher's ca. The hosts's ca located at /etc/kuberneters the rancher's ca can be reached out via https://<your rancher domain>/certs.

Make sure to clean up your previous environment if you are trying to reset a node created by rancher or kubeadm. e.g. here is what I used to reset the node, check each command before run:

docker rm -f $(docker ps -a | grep rancher | awk '{print $1}')
docker rm -f $(docker ps -a | grep k8s | awk '{print $1}')
cd /etc; mv kubernetes kubernetes.rancher.backup
cd ~ ; mv .kube .kube.backup
y | docker volume prune

service docker stop
mount|grep kubelet | awk '{print $3}' | while read mount; do umount $mount; done
rm -rf /var/lib/docker/*
rm -rf /var/lib/rancher/*
rm -rf /var/lib/etcd
rm -rf /var/lib/kubelet/*
rm -rf /etc/kubernetes
rm -rf /etc/cni
rm -rf /opt/cni
rm -rf /var/lib/cni
rm -rf /var/run/calico
rm -rf /run/secrets/kubernetes.io
test -d /opt/rancher && rm -rf /opt/rancher # For Single Rancher installs
test -d /opt/containerd && rm -rf /opt/containerd
test -d /opt/rke && rm -rf /opt/rke
echo "check docker lib" ;ll /var/lib/docker/
echo "restart dockr"
service docker restart
echo "check docker lib" ;ll /var/lib/docker/

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 Dylan