kubeadm初始化kubernetes报错:

报错一:

error execution phase preflight: [preflight] Some fatal errors occurred:
[ERROR FileAvailable–etc-kubernetes-manifests-kube-apiserver.yaml]: /etc/kubernetes/manifests/kube-apiserver.yaml already exists
[ERROR FileAvailable–etc-kubernetes-manifests-kube-controller-manager.yaml]: /etc/kubernetes/manifests/kube-controller-manager.yaml already exists
[ERROR FileAvailable–etc-kubernetes-manifests-kube-scheduler.yaml]: /etc/kubernetes/manifests/kube-scheduler.yaml already exists
[ERROR FileAvailable–etc-kubernetes-manifests-etcd.yaml]: /etc/kubernetes/manifests/etcd.yaml already exists
[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
解决:

kubeadm reset

然后重新初始化!

报错二:

[kubelet-check] Initial timeout of 40s passed.
[kubelet-check] It seems like the kubelet isn’t running or healthy.
[kubelet-check] The HTTP call equal to ‘curl -sSL http://localhost:10248/healthz’ failed with error: Get “http://localhost:10248/healthz”: dial tcp [::1]:10248: connect: connection refused.

出现报错后,执行 tail /var/log/messages > error
查看报错信息:

cat error

Jun 9 22:15:56 master kubelet: E0609 22:15:56.367821 12257 node_container_manager_linux.go:61] “Failed to create cgroup” err=“Cannot set property TasksAccounting, or unknown property.” cgroupName=[kubepods]
Jun 9 22:15:56 master kubelet: E0609 22:15:56.367834 12257 kubelet.go:1431] “Failed to start ContainerManager” err=“Cannot set property TasksAccounting, or unknown property.”
Jun 9 22:15:56 master systemd: kubelet.service: main process exited, code=exited, status=1/FAILURE
Jun 9 22:15:56 master systemd: Unit kubelet.service entered failed state.
Jun 9 22:15:56 master systemd: kubelet.service failed.

更新 systemd

[root@master ~]# kubelet --version
Kubernetes v1.23.1
[root@master ~]# yum info systemd
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Installed Packages
Name        : systemd
Arch        : x86_64
Version     : 219
Release     : 78.el7

yum list kubelet
卸载现有的低版本
yum remove systemd
重新安装高版本
yum install systemd
kubeadm reset
重新初始化:
kubeadm init --config kubeadm-init.yaml

我出现该报错的原因是使用的rhel7.3,systemd版本太低,更新systemd后重新初始化成功。
出现该问题的原因还可能是kubelet的cgroup driver和containerd的 cgroup driver二者不一致致使kubelet启动失败。我这里使用的kubele和container的 cgroup driver是systemd。

Logo

开源、云原生的融合云平台

更多推荐