k8s 1.18.2 将docker切换为containerd

1.查看现在的K8S状态

[root@ecs-arm-ky-001 ~]# kubectl get nodes -o wide
NAME             STATUS   ROLES    AGE   VERSION   INTERNAL-IP     EXTERNAL-IP   OS-IMAGE                                   KERNEL-VERSION              CONTAINER-RUNTIME
ecs-arm-ky-001   Ready    master   12d   v1.18.2   192.168.0.206   <none>        Kylin Linux Advanced Server V10 (Tercel)   4.19.90-17.5.ky10.aarch64   docker://20.10.9
ecs-arm-ky-002   Ready    <none>   12d   v1.18.2   192.168.0.208   <none>        Kylin Linux Advanced Server V10 (Tercel)   4.19.90-17.5.ky10.aarch64   docker://20.10.9
[root@ecs-arm-ky-001 ~]# 

2.在master上操作

将需要切换的node换成不可调度

[root@ecs-arm-ky-001 ~]# kubectl cordon ecs-arm-ky-002
node/ecs-arm-ky-002 cordoned
[root@ecs-arm-ky-001 ~]# 

3查看状态

[root@ecs-arm-ky-001 ~]# kubectl get node
NAME             STATUS                     ROLES    AGE   VERSION
ecs-arm-ky-001   Ready                      master   12d   v1.18.2
ecs-arm-ky-002   Ready,SchedulingDisabled   <none>   12d   v1.18.2
[root@ecs-arm-ky-001 ~]# 

4.在切换引擎的Node的服务器上操作

1.配置先决条件

cat <<EOF | sudo tee /etc/modules-load.d/containerd.conf
overlay
br_netfilter
EOF

sudo modprobe overlay
sudo 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 参数而无需重新启动
sudo sysctl --system

 2.安装containerd 参考https://www.cnblogs.com/tian880820/p/16079599.html

 3.配置config.toml文件

containerd config default | sudo tee /etc/containerd/config.toml

4.修改配置文件

sandbox_image:将镜像地址替换为国内阿里云的
SystemdCgroup:指定使用systemd作为Cgroup的驱动程序(在options下一行添加的内容)
endpoint:修改镜像加速地址

cat -n  /etc/containerd/config.toml |egrep "sandbox_image|SystemdCgroup |endpoint "
    57        sandbox_image = "registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.2"    
    97              SystemdCgroup = true
   106              endpoint = ["https://1nj0zren.mirror.aliyuncs.com"]

5.重启containerd

systemctl restart containerd.service
systemctl enable containerd.service

6.配置kubelet使用containerd

cat  /etc/sysconfig/kubelet
KUBELET_EXTRA_ARGS="--container-runtime=remote --container-runtime-endpoint=unix:///run/containerd/containerd.sock --cgroup-driver=systemd"

 7.重启kubelet

systemctl restart kubelet

查看容器引擎是否成功切换为containerd

查看容器引擎是否成功切换为containerd

[root@ecs-arm-ky-001 ~]# kubectl get nodes -o wide
NAME             STATUS                     ROLES    AGE   VERSION   INTERNAL-IP     EXTERNAL-IP   OS-IMAGE                                   KERNEL-VERSION              CONTAINER-RUNTIME
ecs-arm-ky-001   Ready                      master   12d   v1.18.2   192.168.0.206   <none>        Kylin Linux Advanced Server V10 (Tercel)   4.19.90-17.5.ky10.aarch64   docker://20.10.9
ecs-arm-ky-002   Ready,SchedulingDisabled   <none>   12d   v1.18.2   192.168.0.208   <none>        Kylin Linux Advanced Server V10 (Tercel)   4.19.90-17.5.ky10.aarch64   containerd://1.6.0

取消node节点不可被调度的标记

[root@ecs-arm-ky-001 ~]# kubectl uncordon ecs-arm-ky-002
node/ecs-arm-ky-002 uncordoned
[root@ecs-arm-ky-001 ~]# kubectl get nodes -o wide
NAME             STATUS   ROLES    AGE   VERSION   INTERNAL-IP     EXTERNAL-IP   OS-IMAGE                                   KERNEL-VERSION              CONTAINER-RUNTIME
ecs-arm-ky-001   Ready    master   12d   v1.18.2   192.168.0.206   <none>        Kylin Linux Advanced Server V10 (Tercel)   4.19.90-17.5.ky10.aarch64   docker://20.10.9
ecs-arm-ky-002   Ready    <none>   12d   v1.18.2   192.168.0.208   <none>        Kylin Linux Advanced Server V10 (Tercel)   4.19.90-17.5.ky10.aarch64   containerd://1.6.0

 

posted @ 2022-04-07 15:43  丶蜡笔小兴  阅读(383)  评论(0编辑  收藏  举报