kubeadm init报错
kubeadm init --config /etc/kubernetes/kubeadm.conf -v 4 --skip-phases=addon/kube-proxy
This can take up to 4m0s", “[kubelet-check] Initial timeout of 40s passed.”, “”, “\tUnfortunately, an error has occurred:”, “\t\ttimed out waiting for the condition”, “”, “\tThis error is likely caused by:”, “\t\t- The kubelet is not running”, “\t\t- The kubelet is unhealthy due to a misconfiguration of the node in some way (required cgroups disabled)”, “”, “\tIf you are on a systemd-powered system, you can try to troubleshoot the error with the following commands:”, “\t\t- ‘systemctl status kubelet’”, “\t\t- ‘journalctl -xeu kubelet’”, “”, “\tAdditionally, a control plane component may have crashed or exited when started by the container runtime.”, “\tTo troubleshoot, list all containers using your preferred container runtimes CLI.”, “”, “\tHere is one example how you may list all Kubernetes containers running in docker:”, “\t\t- ‘docker ps -a | grep kube | grep -v pause’”, “\t\tOnce you have found the failing container, you can inspect its logs with:”, “\t\t- ‘docker logs CONTAINERID’”]}
排查
systemctl status kubelet
cat /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf
journalctl -xeu kubelet
docker ps -a | grep kube | grep -v pause
cat /etc/docker/daemon.json
根因
The error message “failed: open /etc/resolv.conf: no such file or directory” can be a cause for Kubernetes (k8s) init failure because Kubernetes relies on DNS resolution to function properly, and the missing “/etc/resolv.conf” file can prevent DNS resolution.
To fix this issue, you can try the following steps:
Check if the file exists: Run the following command in the terminal: ls /etc/resolv.conf. If the file exists, it should display the file name. If it doesn’t exist, you’ll need to recreate the file.
Recreate the file: Run the following command in the terminal: sudo touch /etc/resolv.conf. This will create an empty file with the correct name.
Configure the file: You’ll need to add the DNS server information to the file. You can do this by editing the file with a text editor such as nano or vi. Here’s an example of what the file might look like:
nameserver 8.8.8.8
nameserver 8.8.4.4
In this example, we’re using Google’s public DNS servers. You can use any DNS servers you like.
Save the file: Once you’ve added the DNS server information, save the file and exit the text editor.
Restart Kubernetes: After completing these steps, restart Kubernetes by running the appropriate command for your setup. For example, if you’re using kubeadm, you can run sudo systemctl restart kubelet to restart the Kubernetes service.
After completing these steps, try initializing Kubernetes again and see if the error message has been resolved. If you’re still encountering issues, there may be other underlying issues that need to be addressed.