Kubeadm 无法拉取图像(无法确定版本且未找到 cri-dockerd)

Kubeadm 无法拉取图像(无法确定版本且未找到 cri-dockerd)

我为几台 Ubuntu 22.04 服务器进行了全新安装,安装了最新的(1.24.3)kubeadm、kubelet 和 kubectl。我还在使用容器作为 CRI。

当我尝试通过运行预检来启动 K8s 集群时发生错误:

# kubeadm config images pull --kubernetes-version=v1.24.3 --v=5
I0808 04:27:08.139042  475778 initconfiguration.go:117] detected and using CRI socket: unix:///var/run/containerd/containerd.sock
I0808 04:27:08.139530  475778 interface.go:432] Looking for default routes with IPv4 addresses
I0808 04:27:08.139580  475778 interface.go:437] Default route transits interface "ens160"
I0808 04:27:08.140022  475778 interface.go:209] Interface ens160 is up
I0808 04:27:08.140168  475778 interface.go:257] Interface "ens160" has 2 addresses :[10.0.1.12/8 fe80::250:56ff:fe83:e1e3/64].
I0808 04:27:08.140231  475778 interface.go:224] Checking addr  10.0.1.12/8.
I0808 04:27:08.140271  475778 interface.go:231] IP found 10.0.1.12
I0808 04:27:08.140307  475778 interface.go:263] Found valid IPv4 address 10.0.1.12 for interface "ens160".
I0808 04:27:08.140344  475778 interface.go:443] Found active IP 10.0.1.12 
I0808 04:27:08.140415  475778 kubelet.go:218] the value of KubeletConfiguration.cgroupDriver is empty; setting it to "systemd"
exit status 1
output: time="2022-08-08T04:27:08Z" level=fatal msg="unable to determine image API version: 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\""
, error
k8s.io/kubernetes/cmd/kubeadm/app/util/runtime.(*CRIRuntime).PullImage
        cmd/kubeadm/app/util/runtime/runtime.go:121
k8s.io/kubernetes/cmd/kubeadm/app/cmd.PullControlPlaneImages
        cmd/kubeadm/app/cmd/config.go:340
k8s.io/kubernetes/cmd/kubeadm/app/cmd.newCmdConfigImagesPull.func1
        cmd/kubeadm/app/cmd/config.go:312
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).execute
        vendor/github.com/spf13/cobra/command.go:856
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).ExecuteC
        vendor/github.com/spf13/cobra/command.go:974
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).Execute
        vendor/github.com/spf13/cobra/command.go:902
k8s.io/kubernetes/cmd/kubeadm/app.Run
        cmd/kubeadm/app/kubeadm.go:50
main.main
        cmd/kubeadm/kubeadm.go:25
runtime.main
        /usr/local/go/src/runtime/proc.go:250
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1571
failed to pull image "k8s.gcr.io/kube-apiserver:v1.24.3"
k8s.io/kubernetes/cmd/kubeadm/app/cmd.PullControlPlaneImages
        cmd/kubeadm/app/cmd/config.go:341
k8s.io/kubernetes/cmd/kubeadm/app/cmd.newCmdConfigImagesPull.func1
        cmd/kubeadm/app/cmd/config.go:312
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).execute
        vendor/github.com/spf13/cobra/command.go:856
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).ExecuteC
        vendor/github.com/spf13/cobra/command.go:974
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).Execute
        vendor/github.com/spf13/cobra/command.go:902
k8s.io/kubernetes/cmd/kubeadm/app.Run
        cmd/kubeadm/app/kubeadm.go:50
main.main
        cmd/kubeadm/kubeadm.go:25
runtime.main
        /usr/local/go/src/runtime/proc.go:250
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1571

显然,输出结果显示未找到版本,并且未找到 cri-dockerd。这不应该是这种情况,因为我在输出的开头明确指定了 kube 版本,并且它也能够在开头找到 containerd。

cri 插件已经在以下位置禁用/etc/containerd/config.toml

# cat /etc/containerd/config.toml|grep cri   
disabled_plugins = ["cri"]

我是 k8s 的新手,所以不确定它有什么问题。我从一开始就遵循了 k8s 文档,不确定缺少了什么:https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/

答案1

您不应该禁用 cri 插件。

cri从该部分删除然后重新启动容器。

disabled_plugins = []

最好cri-socket在每个 kubeadm 命令中添加选项以防万一:

kubeadm <commands> --cri-socket=/var/run/containerd/containerd.sock

相关内容