问题
执行 crictl version 查看容器运行时接口版本报以下错误
ERRO[0000] unable to determine runtime API version: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing dial unix /var/run/dockershim.sock: connect: no such file or directory"
E0130 16:41:03.478496 110322 remote_runtime.go:189] "Version from runtime service failed" err="rpc error: code = Unimplemented desc = unknown service runtime.v1alpha2.RuntimeService"
FATA[0000] getting the runtime version: rpc error: code = Unimplemented desc = unknown service runtime.v1alpha2.RuntimeService
原因
根据报错信息 crictl 指向文件 unix:///var/run/dockershim.sock , 因为kubernetes 1.24 版本移除了dockershim的支持,Docker Engine不支持CRI规范,为了能够让Kubernetes基于CRI控制Docker而使用的是cri-dockerd运行时。
解决
通过设置 --runtime-endpoint 和 --image-endpoint 指向 cri-dockerd 运行时
crictl config runtime-endpoint unix:///var/run/cri-dockerd.sock
crictl config image-endpoint unix:///var/run/cri-dockerd.sock
# 查看配置是否修改
cat /etc/crictl.yaml
# 再次执行查看运行时OK
crictl version