官方文档:https://kubernetes.io/zh/docs/setup/production-environment/container-runtimes/#containerd
# 1、查看该node当前运行一个名为web-96d5df5c8-s7lnq的pod
# kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
web-96d5df5c8-s7lnq 1/1 Running 0 19m 10.244.58.195 k8s-node02 <none> <none>
# 2、将该node标记为不可被调度
# kubectl cordon k8s-node02
# 3、驱逐该node节点上的pod资源到集群中的其它节点上去
# kubectl drain k8s-node02 --delete-local-data --force --ignore-daemonsets
# 4、查看之前运行在该node上的pod被调度到了集群中的哪个节点
# kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
web-96d5df5c8-m8s7d 1/1 Running 0 57s 10.244.85.195 k8s-node01 <none> <none>
从以上信息来看可以发现,之前k8s-node02节点上的pod资源被驱逐到了k8s-node01上运行
# 5、查看Kubernetes集群中的node资源信息
# kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8s-master01 Ready control-plane,master 4h20m v1.20.0
k8s-node01 Ready <none> 3h47m v1.20.0
k8s-node02 Ready,SchedulingDisabled <none> 3h47m v1.20.0
如上信息,k8s-node02节点已经不可被调度了,接下来开始切换容器引擎
# cat <<EOF | sudo tee /etc/modules-load.d/containerd.conf
overlay
br_netfilter
EOF
# modprobe overlay
# modprobe br_netfilter
# 设置必需的 sysctl 参数,这些参数在重新启动后仍然存在。
# cat <<EOF | sudo tee /etc/sysctl.d/99-kubernetes-cri.conf
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
EOF
# sysctl --system
# yum install -y yum-utils device-mapper-persistent-data lvm2
# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# yum install -y containerd.io
# mkdir -p /etc/containerd
# containerd config default | sudo tee /etc/containerd/config.toml
# systemctl restart containerd.service
# 1、搜索关键字"sandbox_image",将镜像地址替换为国内阿里云的
57 sandbox_image = "registry.aliyuncs.com/google_containers/pause:3.2"
# 2、指定使用systemd作为Cgroup的驱动程序
需要添加,这里是在96后,也可以搜素关键字"options",在其下一行添加如下内容
97 SystemdCgroup = "true"
# 3、搜索关键字"endpoint",修改镜像加速地址
106 endpoint = ["https://5uhltnnr.mirror.aliyuncs.com"]
# 4、重启containerd
# systemctl restart containerd.service
# vim /etc/sysconfig/kubelet
KUBELET_EXTRA_ARGS="--container-runtime=remote --container-runtime-endpoint=unix:///run/containerd/containerd.sock --cgroup-driver=systemd"
# systemctl status kubelet
从上图可以信息结果中,可以发现k8s-node02这个节点当前使用的容器引擎为containerd,至此,成功地将该节点使用的容器引擎从docker切换为containerd,接下来。取消该节点不可被调度的标记,使其可以被正常调度。
# kubectl uncordon k8s-node02
node/k8s-node02 uncordoned
# kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8s-master01 Ready control-plane,master 5h1m v1.20.0
k8s-node01 Ready <none> 4h28m v1.20.0
k8s-node02 Ready <none> 4h28m v1.20.4
原文:https://blog.51cto.com/hexiaoshuai/2664272