[root@slions-pc1 ~]# kubectl get node -o wide NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME slions-pc1 Ready master 2d v1.19.0 192.168.100.10 <none> CentOS Linux 7 (Core) 3.10.0-957.el7.x86_64 containerd://1.4.12
slions_pc1节点的容器运行时已经切换到 containerd://1.4.12 了。
恢复调度
最后把节点重新加回到集群中来允许调度 Pod。
1
kubectl uncordon $<NODE_NAME>
crictl
可以使用 ctr 命令来管理 containerd,查看多了一个名为 k8s.io 的命名空间:
1 2 3 4
[root@slions-pc1 ~]# ctr ns ls NAME LABELS k8s.io moby
[root@slions-pc1 home]# crictl pods POD ID CREATED STATE NAME NAMESPACE ATTEMPT RUNTIME d6fe5b981c93a About an hour ago Ready coredns-6d56c8448f-mlj4r kube-system 0 (default) b5869243675c1 About an hour ago Ready coredns-6d56c8448f-vtx97 kube-system 0 (default) 9545145b2d985 About an hour ago Ready kube-flannel-ds-4qwnd kube-system 0 (default) 71da443d2b400 About an hour ago Ready kube-controller-manager-slions-pc1 kube-system 0 (default) 17ae102739d90 3 hours ago Ready kube-proxy-dd4dg kube-system 0 (default) 71890ef89c6b6 3 hours ago Ready kube-apiserver-slions-pc1 kube-system 0 (default) cad990849d280 3 hours ago Ready etcd-slions-pc1 kube-system 0 (default) 468ae24960d0c 3 hours ago Ready kube-scheduler-slions-pc1 kube-system 0 (default) [root@slions-pc1 home]# crictl pods --name kube-apiserver-slions-pc1 POD ID CREATED STATE NAME NAMESPACE ATTEMPT RUNTIME 71890ef89c6b6 3 hours ago Ready kube-apiserver-slions-pc1 kube-system 0 (default) [root@slions-pc1 home]# crictl pods --label app=flannel POD ID CREATED STATE NAME NAMESPACE ATTEMPT RUNTIME 9545145b2d985 About an hour ago Ready kube-flannel-ds-4qwnd kube-system 0 (default)
[root@slions-pc1 home]# crictl ps CONTAINER IMAGE CREATED STATE NAME ATTEMPT POD ID ec086f05f1063 bfe3a36ebd252 About an hour ago Running coredns 0 d6fe5b981c93a 31e6e8d326192 bfe3a36ebd252 About an hour ago Running coredns 0 b5869243675c1 3fb571cc76791 e6ea68648f0cd About an hour ago Running kube-flannel 0 9545145b2d985 ea80243d5a9e6 09d665d529d07 About an hour ago Running kube-controller-manager 0 71da443d2b400 484541d3b39bb bc9c328f379ce 3 hours ago Running kube-proxy 0 17ae102739d90 6e688d8e85723 1b74e93ece2f5 3 hours ago Running kube-apiserver 0 71890ef89c6b6 2f5c0484bb866 d4ca8726196cb 3 hours ago Running etcd 0 cad990849d280 51e15fd5f4961 cbdc8369d8b15 3 hours ago Running kube-scheduler 0 468ae24960d0c
[root@slions-pc1 home]# crictl ps -s Running CONTAINER IMAGE CREATED STATE NAME ATTEMPT POD ID ec086f05f1063 bfe3a36ebd252 About an hour ago Running coredns 0 d6fe5b981c93a 31e6e8d326192 bfe3a36ebd252 About an hour ago Running coredns 0 b5869243675c1 3fb571cc76791 e6ea68648f0cd About an hour ago Running kube-flannel 0 9545145b2d985 ea80243d5a9e6 09d665d529d07 About an hour ago Running kube-controller-manager 0 71da443d2b400 484541d3b39bb bc9c328f379ce 3 hours ago Running kube-proxy 0 17ae102739d90 6e688d8e85723 1b74e93ece2f5 3 hours ago Running kube-apiserver 0 71890ef89c6b6 2f5c0484bb866 d4ca8726196cb 3 hours ago Running etcd 0 cad990849d280 51e15fd5f4961 cbdc8369d8b15 3 hours ago Running kube-scheduler 0 468ae24960d0c
[root@slions-pc1 home]# crictl exec -it 3fb571cc76791 date Thu Dec 16 12:45:35 UTC 2021
CLI对比
命令
Docker
Containerd
docker
crictl(推荐)
ctr
查看容器列表
docker ps
crictl ps
ctr -n k8s.io c ls
查看容器详情
docker inspect
crictl inspect
ctr -n k8s.io c info
查看容器日志
docker logs
crictl logs
无
容器内执行命令
docker exec
crictl exec
无
挂载容器
docker attach
crictl attach
无
显示容器资源使用情况
docker stats
crictl stats
无
创建容器
docker create
crictl create
ctr -n k8s.io c create
启动容器
docker start
crictl start
ctr -n k8s.io run
停止容器
docker stop
crictl stop
无
删除容器
docker rm
crictl rm
ctr -n k8s.io c del
查看镜像列表
docker images
crictl images
ctr -n k8s.io i ls
查看镜像详情
docker inspect
crictl inspecti
无
拉取镜像
docker pull
crictl pull
ctr -n k8s.io i pull
推送镜像
docker push
无
ctr -n k8s.io i push
删除镜像
docker rmi
crictl rmi
ctr -n k8s.io i rm
查看Pod列表
无
crictl pods
无
查看Pod详情
无
crictl inspectp
无
启动Pod
无
crictl runp
无
停止Pod
无
crictl stopp
无
crictl pods 列出的是 Pod 的信息,包括 Pod 所在的命名空间以及状态。crictl ps 列出的是应用容器的信息,而 docker ps 列出的是初始化容器(pause 容器)和应用容器的信息,初始化容器在每个 Pod 启动时都会创建,通常不会关注,所以 crictl 使用起来更简洁明了一些。