kubernetes(kubeadm)集群的安装问题总结
2021-02-19 07:17
标签:初始化 different 技术 cpu vmware虚拟机 check docker使用 UNC 新建 2)修改/var/lib/kubelet/kubeadm-flags.env驱动配置,添加--cgroup-driver=systemd 参数 3、kubeadm初始化时报[ERROR NumCPU] kubernetes(kubeadm)集群的安装问题总结 标签:初始化 different 技术 cpu vmware虚拟机 check docker使用 UNC 新建 原文地址:https://blog.51cto.com/8355320/2497457
异常【kubelet cgroup driver:cgroupfs跟docker cgroup driver:systemd不一致】
异常描述如下:
failed to create kubelet: misconfiguration: kubelet cgroup driver: "cgroupfs" is different from docker cgroup driver: "systemd"
kubelet文件驱动默认cgroupfs, 而安装的docker使用的文件驱动是systemd, 造成不一致, 导致镜像无法启动。
1)确认docker配置文件daemon.json的驱动配置
[root@master~]# cat /etc/docker/daemon.json
{
"registry-mirrors": ["https://b9pmyelo.mirror.aliyuncs.com"],
"exec-opts": ["native.cgroupdriver=systemd"]
}
[root@master~]# cat /var/lib/kubelet/kubeadm-flags.env
KUBELET_KUBEADM_ARGS="--cgroup-driver=systemd --network-plugin=cni --pod-infra-container-image=registry.aliyuncs.com/google_containers/pause:3.1"
#重启docker与kubelet
[root@master~]# systemctl daemon-reload && systemctl restart docker kubelet
2、/system.slice/kubelet.service无法识别异常描述如下
failed to get container info for "/system.slice/kubelet.service": unknown container "/system.slice/kubelet.service"
修改kubelet.service
[root@master~]# vim /lib/systemd/system/kubelet.service
#在ExecStart位置最后面,添加如下配置
--runtime-cgroups=/systemd/system.slice --kubelet-cgroups=/systemd/system.slice
kubeadm init --apiserver-advertise-address=10.10.10.129 --image-repository registry.aliyuncs.com/google_contain
ers --kubernetes-version v1.17.0 --service-cidr=10.96.0.0/12 --pod-network-cidr=10.244.0.0/16W0521 22:45:14.131024 8293 validation.go:28] Cannot validate kube-proxy config - no validator is available
W0521 22:45:14.131095 8293 validation.go:28] Cannot validate kubelet config - no validator is available
[init] Using Kubernetes version: v1.17.0
[preflight] Running pre-flight checks
error execution phase preflight: [preflight] Some fatal errors occurred:
[ERROR NumCPU]: the number of available CPUs 1 is less than the required 2
[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
这种错误一般会出现在VMware虚拟机上,因为新建VM时默认为一核,可通过配置,调整成2核,重启系统即可,如下所示:
根据提示添加忽略错误提示--ignore-preflight-errors=...
$ kubeadm init --apiserver-advertise-address=10.10.10.129 --image-repository registry.aliyuncs.com/google_containers --kubernetes-version v1.17.0 --service-cidr=10.96.0.0/12 --pod-network-cidr=10.244.0.0/16 --ignore-preflight-errors=NumCPU
文章标题:kubernetes(kubeadm)集群的安装问题总结
文章链接:http://soscw.com/index.php/essay/57415.html