Due to the requirements of the new versions of Docker and Kubernetes for the system, the following operations must first be performed to ensure that Docker and kubelet can work properly.
First, modify or add the /etc/docker/daemon.json
file with the following content:
{
"registry-mirrors": ["https://94zlnekp1.mirror.aliyuncs.com"],
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "1"
},
"exec-opts": ["native.cgroupdriver=systemd"]
}
94zlnekp1.mirror.aliyuncs.com
is a personal Docker acceleration address.
Restart Docker:
sudo systemctl daemon-reload
sudo systemctl restart docker
This step primarily addresses the cgroups
issue.
This error is likely caused by:
- The kubelet is not running
- The kubelet is unhealthy due to a misconfiguration of the node in some way (required cgroups disabled)
Next, disable swap, which is a requirement for kubelet.
Turn off virtual memory:
swapoff -a
Modify the configuration:
nano /etc/fstab
Delete this line:
/swap.img none swap sw 0 0
Then delete the swap.img
file.
Next, restart the container runtime:
systemctl restart containerd
If you check the logs with journalctl -xeu kubelet
and find:
"Error getting node" err="node \"k8smain\" not found"
You can open the /etc/hosts
file and add or modify the IP corresponding to the current machine name.
127.0.0.1 myhost
If multiple nodes are needed, then each node must be configured with the internal IP of the master node.
If you encounter:
r="failed to run Kubelet: unable to determine runtime API version: rpc error: code = Unavailable d
Then run:
crictl config runtime-endpoint unix:///run/containerd/containerd.sock
crictl config image-endpoint unix:///run/containerd/containerd.sock
Then check:
systemctl status containerd -l
文章评论