lework/kainstall

kubeadm init failed

comvir opened this issue · 7 comments

执行的命令

bash kainstall-centos.sh init \
  --master 192.168.0.59 \
  --worker 192.168.0.59 \
  --user root \
  --password P@ssw0rd123 \
  --version 1.22.3 \
  --10years \
  --offline-file 1.22.3_centos7.tgz

最后一条出错的日志

[2021-11-08T09:06:55.764277829+0800]: �[34mEXEC:    �[0m[command] sshpass -p "zzzzzz" ssh -o ConnectTimeout=600 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@192.168.0.59 -p 22 bash -c 'kubeadm init --config=/etc/kubernetes/kubeadmcfg.yaml --upload-certs'
Warning: Permanently added '192.168.0.59' (ECDSA) to the list of known hosts.
invalid or incomplete external CA: failure loading key for apiserver: couldn't load the private key file /etc/kubernetes/pki/apiserver.key: open /etc/kubernetes/pki/apiserver.key: no such file or directory
To see the stack trace of this error execute with --v=5 or higher
[2021-11-08T09:06:56.107721125+0800]: �[31mERROR:   �[0m[kubeadm init] 192.168.0.59: kubeadm init failed.

你想要一个节点使用,可以只指定master就行,这样就会启用master的worker属性。

bash kainstall-centos.sh init \
  --master 192.168.0.59 \
  --user root \
  --password P@ssw0rd123 \
  --version 1.22.3 \
  --10years \
  --offline-file 1.22.3_centos7.tgz

你想要一个节点使用,可以只指定master就行,这样就会启用master的worker属性。

bash kainstall-centos.sh init \
  --master 192.168.0.59 \
  --user root \
  --password P@ssw0rd123 \
  --version 1.22.3 \
  --10years \
  --offline-file 1.22.3_centos7.tgz

问题还在,一样的错误日志

可以加入这个QQ群,467645743 。 把log文件发给我,我看看啥问题。

可以加入这个QQ群,467645743 。 把log文件发给我,我看看啥问题。

可能是之前装过k8s的卸载残留影响了脚本判断,删掉"/etc/kubernetes"和"$HOME/.kube"后再执行出现新的错误。
日志

[kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get "http://localhost:10248/healthz": dial tcp 0.0.0.0:10248: connect: connection refused.
error execution phase wait-control-plane: couldn't initialize a Kubernetes cluster
To see the stack trace of this error execute with --v=5 or higher

	Unfortunately, an error has occurred:
		timed out waiting for the condition

	This error is likely caused by:
		- The kubelet is not running
		- The kubelet is unhealthy due to a misconfiguration of the node in some way (required cgroups disabled)

	If you are on a systemd-powered system, you can try to troubleshoot the error with the following commands:
		- 'systemctl status kubelet'
		- 'journalctl -xeu kubelet'

	Additionally, a control plane component may have crashed or exited when started by the container runtime.
	To troubleshoot, list all containers using your preferred container runtimes CLI.

	Here is one example how you may list all Kubernetes containers running in docker:
		- 'docker ps -a | grep kube | grep -v pause'
		Once you have found the failing container, you can inspect its logs with:
		- 'docker logs CONTAINERID'

[2021-11-08T14:24:57.305494981+0800]: �[31mERROR:   �[0m[kubeadm init] 192.168.0.59: kubeadm init failed.

使用 bash kainstall-centos.sh reset 重置下环境吧。

使用 bash kainstall-centos.sh reset 重置下环境吧。

reset会报"get all_node value failed"

[2021-11-08T15:15:06.307783143+0800]: �[34mEXEC:    �[0m[command] bash -c '
    kubectl get node -o jsonpath='"'"'{range.items[*]}{.status.addresses[?(@.type=="InternalIP")].address} {end}'"'"'
  '
W1108 15:15:06.359132   56266 loader.go:221] Config not found: /root/.kube/config
The connection to the server localhost:8080 was refused - did you specify the right host or port?
[2021-11-08T15:15:06.368955289+0800]: �[31mERROR:   �[0m[command] get all_node value failed.

通过某脚本把k8s的残留全清,再次init出现新的问题
cannot execute 'kubelet --version'

[init] Using Kubernetes version: v1.22.3
[preflight] Running pre-flight checks
error execution phase preflight: [preflight] Some fatal errors occurred:
	[ERROR KubeletVersion]: couldn't get kubelet version: cannot execute 'kubelet --version': executable file not found in $PATH
[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
[2021-11-08T16:06:05.853052958+0800]: �[31mERROR:   �[0m[kubeadm init] 192.168.0.59: kubeadm init failed.

因为集群没有建立成功,所以要加上节点,才能重置。

bash kainstall-centos.sh reset --master 192.168.0.59 --user root --password P@ssw0rd123