【kubeadm初始化kubernetes报错以及解决】古人学问无遗力,少壮工夫老始成。这篇文章主要讲述kubeadm初始化kubernetes报错以及解决相关的知识,希望能为你提供帮助。
1、报错
[root@master ~]# kubeadm init --kubernetes-version=v1.21.0 --pod-network-cidr=172.16.0.0/16 --service-cidr=172.18.0.0/16
[init] Using Kubernetes version: v1.21.0
[preflight] Running pre-flight checks
[WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/
[WARNING Hostname]: hostname "master" could not be reached
[WARNING Hostname]: hostname "master": lookup master on 172.16.0.2:53: no such host
error execution phase preflight: [preflight] Some fatal errors occurred:
[ERROR NumCPU]: the number of available CPUs 1 is less than the required 2
[ERROR Swap]: running with swap on is not supported. Please disable swap
[ERROR KubeletVersion]: the kubelet version is higher than the control plane version. This is not a supported version skew and may lead to a malfunctional cluster. Kubelet version: "1.22.2" Control plane version: "1.21.0"
[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
2、解决方法
错误一:
[WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/
解决方法:"exec-opts": ["native.cgroupdriver=systemd"]
加入下面一行
[root@master ~]# vim /etc/docker/daemon.json
"registry-mirrors": ["https://q2hy3fzi.mirror.aliyuncs.com"],
"exec-opts": ["native.cgroupdriver=systemd"]
}错误二:
[WARNING Hostname]: hostname "master" could not be reached
解决方法:
所有节点修改host文件
[root@master ~]# vim /etc/hosts
127.0.0.1localhost localhost.localdomain localhost4 localhost4.localdomain4
::1localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.128.12master
172.16.128.0node1
172.16.128.13node2错误三:
[ERROR NumCPU]: the number of available CPUs 1 is less than the required 2
解决方法:
其一: 虚拟机话,可以提升虚拟机的cpu资源
其二: 忽视这条告警错误,加上 --ignore-preflight-errors=all 参数即可。错误四:
[ERROR Swap]: running with swap on is not supported. Please disable swap
解决方法:
关闭swap并且修改fstab文件
[root@master ~]# swapoff -a
[root@master ~]# vim /etc/fstab
# /etc/fstab
# Created by anaconda on Thu Sep 23 17:45:45 2021
# Accessible filesystems, by reference, are maintained under \'/dev/disk\'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=be2920b0-9460-45c5-ab99-25f875fe44ce /xfsdefaults0 0
UUID=5b946178-29ba-4e71-80fa-168971ee2d3f /bootxfsdefaults0 0
UUID=ebbb0118-c740-4025-87a2-ed4e073d2b03 /dataext4defaults1 2
#UUID=fcb0ec3c-731d-44a6-86dd-ae284fe407ac swapswapdefaults0 0错误五:
[ERROR KubeletVersion]: the kubelet version is higher than the control plane version.
解决方法:
忽略这条报错,这是因为kubelet版本太新导致的
[root@master ~]# vim /etc/sysconfig/kubelet
KUBELET_EXTRA_ARGS="--fail-swap-on=false"
3、kubeadm初始化kubernetes
[root@master ~]# kubeadm init --kubernetes-version=v1.21.0 --pod-network-cidr=172.16.0.0/16 --service-cidr=172.18.0.0/16 --ignore-preflight-errors=all
推荐阅读
- 用Python绘制移动均线含源代码
- t-io网络编程基础知识介绍
- 2021.7 货拉拉虾皮有赞。。。高级前端岗面试整理
- 鸿蒙应用开发(如何与组件库(Glide)衔接())
- Interrupted Exception异常可能没你想的那么简单!
- 奇思妙想(小程序wxapkg包一键运行至浏览器())
- sftp&&psftp使用
- prometheus snmp_exporter使用
- 计算机的网络参考模型