[root@master01 ~]# kubeadm init \> --apiserver-advertise-address=10.202.99.128 \> --control-plane-endpoint=master01 \> --image-repository registry.cn-guangzhou.aliyuncs.com/my_aliyund \> --kubernetes-version v1.30.2 \> --service-cidr=10.10.0.0/12 \> --pod-network-cidr=10.254.0.0/16
[init] Using Kubernetes version: v1.30.2
[preflight] Running pre-flight checks
error execution phase preflight: [preflight] Some fatal errors occurred:
[ERROR CRI]: container runtime is not running: output: time="2024-07-18T03:14:29-04:00"level=fatal msg="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"
, 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
###################### 解决方法# vim /etc/containerd/config.toml# SystemdCgroup 参数配置为 true
SystemdCgroup =true# 所有的 runtime_type 参数配置为 io.containerd.runtime.v1.linux
runtime_type ="io.containerd.runtime.v1.linux"# 重启 containerd
systemctl restart containerd
## 解决初始化containerd错误的文章
https://zhuanlan.zhihu.com/p/618551600
4.3、初始化成功信息
Your Kubernetes control-plane has initialized successfully!
To start using your cluster, you need to run the following as a regular user:
mkdir-p$HOME/.kube
sudocp-i /etc/kubernetes/admin.conf $HOME/.kube/config
sudochown$(id-u):$(id-g)$HOME/.kube/config
Alternatively, if you are the root user, you can run:
exportKUBECONFIG=/etc/kubernetes/admin.conf
You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
https://kubernetes.io/docs/concepts/cluster-administration/addons/
You can now join any number of control-plane nodes by copying certificate authorities
and service account keys on each node and then running the following as root:
kubeadm join master01:6443 --token rdn0pu.r6kxla7vzf4bcftt \
--discovery-token-ca-cert-hash sha256:611744ae7304f5c18cf46ca3bba42d5b6f5aa671173249fa1a17088ab37308ee \
--control-plane
Then you can join any number of worker nodes by running the following on each as root:
kubeadm join master01:6443 --token rdn0pu.r6kxla7vzf4bcftt \
--discovery-token-ca-cert-hash sha256:611744ae7304f5c18cf46ca3bba42d5b6f5aa671173249fa1a17088ab37308ee
4.4、加入节点
# 如发生错误# E0401 02:25:24.207258 6245 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connect: connection refused# 临时解决方案exportKUBECONFIG=/etc/kubernetes/admin.conf
# 长期解决方案mkdir ~/.kube
cp /etc/kubernetes/admin.conf ~/.kube/config
# 到需要加入集群的节点执行# 加入master节点
kubeadm join master01:6443 --token rdn0pu.r6kxla7vzf4bcftt \
--discovery-token-ca-cert-hash sha256:611744ae7304f5c18cf46ca3bba42d5b6f5aa671173249fa1a17088ab37308ee \
--control-plane
# 加入node节点
kubeadm join master01:6443 --token rdn0pu.r6kxla7vzf4bcftt \
--discovery-token-ca-cert-hash sha256:611744ae7304f5c18cf46ca3bba42d5b6f5aa671173249fa1a17088ab37308ee