錯誤完整訊息:
ubuntu@my-instance:~$ sudo kubeadm init \\
--pod-network-cidr=10.10.0.0/16 \\
--control-plane-endpoint=master:6443
I0802 23:10:51.195543 165289 version.go:261] remote version is much newer: v1.33.3; falling back to: stable-1.32
[init] Using Kubernetes version: v1.32.7
[preflight] Running pre-flight checks
W0802 23:10:51.707665 165289 checks.go:1077] [preflight] WARNING: Couldn't create the interface used for talking to the container runtime: failed to create new CRI runtime service: validate service connection: validate CRI v1 runtime API for endpoint "unix:///var/run/containerd/containerd.sock": rpc error: code = Unimplemented desc = unknown service runtime.v1.RuntimeService
[preflight] Pulling images required for setting up a Kubernetes cluster
[preflight] This might take a minute or two, depending on the speed of your internet connection
[preflight] You can also perform this action beforehand using 'kubeadm config images pull'
error execution phase preflight: [preflight] Some fatal errors occurred:
failed to create new CRI runtime service: validate service connection: validate CRI v1 runtime API for endpoint "unix:///var/run/containerd/containerd.sock": rpc error: code = Unimplemented desc = unknown service runtime.v1.RuntimeService[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher
Why? containerd config 未開啟 cri Plugin
$ cat /etc/containerd/config.toml
# ... 略 ...
disabled_plugins = ["cri"] # 這行就是導致錯誤的原因
上面的輸出意思是:「把 CRI plugin 關掉。」
而 Kubernetes 的 kubelet 和 kubeadm 在啟動時,一定要透過 CRI(Container Runtime Interface)去控制 container runtime
解決方式
containerd/docs/getting-started.md at main · containerd/containerd
Note:
If you installed containerd from a package (for example, RPM or
.deb), you may find that the CRI integration plugin is disabled by default.You need CRI support enabled to use containerd with Kubernetes. Make sure that
criis not included in thedisabled_pluginslist within/etc/containerd/config.toml; if you made changes to that file, also restartcontainerd.If you experience container crash loops after the initial cluster installation or after installing a CNI, the containerd configuration provided with the package might contain incompatible configuration parameters. Consider resetting the containerd configuration with
containerd config default > /etc/containerd/config.tomlas specified in getting-started.md and then set the configuration parameters specified above accordingly.