修改NODE节点的cri-socket

kubectl edit nodes d0-dev-master002
修改 
kubeadm.alpha.kubernetes.io/cri-socket: /var/run/dockershim.sock
改为 
kubeadm.alpha.kubernetes.io/cri-socket: /var/run/containerd/containerd.sock

在主节点上驱逐节点pod并标记为不可调度

kubectl drain d0-dev-master002 --ignore-daemonsets

登到d0-dev-master002卸载Docker

#停掉Docker相关
systemctl stop kubelet 
systemctl disable docker --now
systemctl disable docker.socket --now
yum remove docker-ce docker-ce-cli -y

安装containerd

yum install -y yum-utils device-mapper-persistent-data lvm2 containerd
containerd config default > /etc/containerd/config.toml
sed -i s#'registry.k8s.io'#'registry.cn-hangzhou.aliyuncs.com/google_containers'#g /etc/containerd/config.toml
sed -i s#'SystemdCgroup = false'#'SystemdCgroup = true'#g /etc/containerd/config.toml
sed -i '/mirrors/ {
    a \ \ \ \ \ \ \ \ [plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]
    a \ \ \ \ \ \ \ \ \ \ endpoint = ["http://hub-mirror.c.163.com","https://docker.mirrors.ustc.edu.cn","https://registry.docker-cn.com"]
}' /etc/containerd/config.toml
echo 'KUBELET_EXTRA_ARGS="--container-runtime=remote --container-runtime-endpoint=unix:///run/containerd/containerd.sock"' >>/etc/sysconfig/kubelet

启动kubelt,这中间kubelet可能会重启几次,耐心等待

systemctl daemon-reload 
systemctl enable --now containerd && systemctl status containerd
systemctl restart kubelet && systemctl status kubelet

可通过如下命令查看集群状态

kubectl get events --all-namespaces --sort-by='.metadata.creationTimestamp'

重启机器立马ready了

安装相关容器工具

crictl是k8s默认工具

echo 'runtime-endpoint: unix:///var/run/containerd/containerd.sock
image-endpoint: unix:///var/run/containerd/containerd.sock
debug: false
pull-image-on-create: false
disable-pull-on-run: false' >/etc/crictl.yaml
crictl pods
crictl pods --name kube-proxy-dnljx
crictl images


但是习惯docker命令的建议可以使用nerdctl

cd /tmp
wget http://1.116.235.157:1080/software/nerdctl-1.6.0-linux-amd64.tar.gz
tar zxvf nerdctl-1.6.0-linux-amd64.tar.gz
cp nerdctl /usr/local/sbin
nerdctl -n k8s.io ps
nerdctl -n k8s.io images