kubernets报错The connection to the server 192.168.117.141:6443 was refused - did you specify the right

 admin   2024-07-31 09:44   129 人阅读  23 条评论

先排错,用crictl ps查看一下容器,果然报没有

/var/run/cri-dockerd.sock这个文件
[root@kmaster ~]# crictl images
WARN[0000] image connect using default endpoints: [unix:///var/run/dockershim.sock unix:///run/containerd/containerd.sock unix:///run/crio/crio.sock unix:///var/run/cri-dockerd.sock]. As the default settings are now deprecated, you should set the endpoint instead. 
E0731 09:40:43.405520    1783 remote_image.go:119] "ListImages with filter from image service failed" err="rpc error: code = Unavailable desc = connection error: desc = \"transport: Error while dialing dial unix /var/run/dockershim.sock: connect: no such file or directory\"" filter="&ImageFilter{Image:&ImageSpec{Image:,Annotations:map[string]string{},},}"
FATA[0000] listing images: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing dial unix /var/run/dockershim.sock: connect: no such file or directory" 
[root@kmaster ~]# crictl config runtime-endpoint unix:///var/run/cri-dockerd.sock
[root@kmaster ~]# crictl images
E0731 09:41:23.834852    1825 remote_image.go:119] "ListImages with filter from image service failed" err="rpc error: code = Unavailable desc = connection error: desc = \"transport: Error while dialing dial unix /var/run/cri-dockerd.sock: connect: no such file or directory\"" filter="&ImageFilter{Image:&ImageSpec{Image:,Annotations:map[string]string{},},}"
FATA[0000] listing images: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing dial unix /var/run/cri-dockerd.sock: connect: no such file or directory" 

crictl依次查找容器运行时,当查找第一个 unix:///var/run/dockershim.sock 没有找到,所以报错了,需要你手动指定当前kubernetes的容器运行时,使用什么,例如:

kubernetes 1.24+ 之后,如果dockershim已经变成了cri-docker,所以你需要执行:

crictl config runtime-endpoint unix:///var/run/cri-dockerd.sock 

如果你的容器运行时,已经换成了containerd,则换成containerd的,如:

crictl config runtime-endpoint unix:///var/run/containerd/containerd.sock

之后,在执行就好了。systemctl status docker.service在cgroup栏下面可以体现

查看自己的容器运行时,使用

[root@kmaster ~]# systemctl status docker.service
TriggeredBy: ● docker.socket
Main PID: 1429 (dockerd)
Tasks: 10
Memory: 109.9M
CPU: 1.168s
CGroup: /system.slice/docker.service
└─1429 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

另外:生成的配置在cat /etc/crictl.yaml,可以随时修改。

本文地址:https://liuchunjie.top/?id=744
版权声明:本文为原创文章,版权归 admin 所有,欢迎分享本文,转载请保留出处!

 发表评论


表情

 评论列表