希望能写一些简单的教程和案例分享给需要的人
通过命令 kubelet version 查看版本号
kubeadm version

ip addr

参考文档 【ubuntu 安装 docker】ubuntu 安装 docker
安装完成后,通过 docker version 来确认安装完成:
我们可以看到版本号 20.10.21

运行初始化命令:
sudo kubeadm init --kubernetes-version=v1.25.4 --apiserver-advertise-address=192.168.133.134 --image-repository=registry.aliyuncs.com/google_containers --service-cidr=10.96.0.0/12 --pod-network-cidr=10.244.0.0/16
上面 3.4.5 可以不用改,1和2中的描述改成对应的信息
sudo kubeadm init --kubernetes-version=v1.25.4 --apiserver-advertise-address=192.168.133.134 --image-repository=registry.aliyuncs.com/google_containers --service-cidr=10.96.0.0/12 --pod-network-cidr=10.244.0.0/16

报错:
[init] Using Kubernetes version: v1.25.4
[preflight] Running pre-flight checks
[WARNING Swap]: swap is enabled; production deployments should disable swap unless testing the NodeSwap feature gate of the kubelet
error execution phase preflight: [preflight] Some fatal errors occurred:
[ERROR CRI]: container runtime is not running: output: E1122 19:13:55.037510 44131 remote_runtime.go:948] "Status from runtime service failed" err="rpc error: code = Unimplemented desc = unknown service runtime.v1alpha2.RuntimeService"
time="2022-11-22T19:13:55-08:00" level=fatal msg="getting status of runtime: rpc error: code = Unimplemented desc = unknown service runtime.v1alpha2.RuntimeService"
, error: exit status 1
[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
我们可以通过命令临时关闭 :
(开机后只要运行一次,重启后恢复)
sudo swapoff -a
sudo vim /etc/containerd/config.toml

注释掉 disabled_plugins= [“cri”] 这行
然后保存退出后
sudo systemctl restart containerd
sudo kubeadm reset
sudo kubeadm init --kubernetes-version=v1.25.4 --apiserver-advertise-address=192.168.133.134 --image-repository=registry.aliyuncs.com/google_containers --service-cidr=10.96.0.0/12 --pod-network-cidr=10.244.0.0/16

sudo vim /etc/docker/daemon.json
{
"exec-opts": ["native.cgroupdriver=systemd"]
}
sudo systemctl daemon-reload
sudo systemctl restart docker
sudo swapoff -a
sudo kubeadm reset
sudo systemctl daemon-reload
sudo systemctl restart kubelet
sudo iptables -F
sudo iptables -t nat -F
sudo iptables -t mangle -F
sudo iptables -X