我已经在主节点上使用kubeadm
安装了K8。但是,当我尝试运行kubectl cluster-info
时,会收到以下响应:
The connection to the server <host>:6443 was refused - did you specify the right host or port?
我确实确保交换已关闭,KUBECONFIG
设置正确,.kube/config
正确,它正在侦听端口6443,已禁用防火墙。我确实发现的两个问题是,cache
目录中没有http-cache
或.kube
文件,而当我执行docker container ls
或{{ 1}}。但是,我可以看到docker ps
提供了容器的图像。
运行docker image ls
时,我得到以下信息:
systemctl status kubelet
检查我找到的Kubelet日志(已修剪):
kubelet.service - kubelet: The Kubernetes Node Agent
Loaded: loaded (/lib/systemd/system/kubelet.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/kubelet.service.d
└─10-kubeadm.conf
Active: activating (auto-restart) (Result: exit-code) since Wed 2019-XX-XX XX:XX:XX XXX; 1s ago
Docs: https://kubernetes.io/docs/home/
Process: 6541 ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS (code=exited, status=255)
Main PID: 6541 (code=exited, status=255)
最后,使用错误的群集证书会遇到相同的错误,但是当我更改用户证书时会遇到身份验证错误。
我不确定如何解决此问题。
答案 0 :(得分:0)
您的kubelet.service
日志为您提供了问题所在的简单明了的答案。如您所见,在运行systemctl status kubelet
之后,t带有作为环境变量传递的以下参数:
Process: 6541 ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS
但失败了:
Main PID: 6541 (code=exited, status=255)
如您在kubelet.service
日志中进一步看到的那样:
F1120 04:53:12.437733 9430 server.go:196] failed to load Kubelet config file
kubelet.service: Main process exited, code=exited, status=255/n/a
kubelet.service: Failed with result 'exit-code'.
Stopped kubelet: The Kubernetes Node Agent.
Started kubelet: The Kubernetes Node Agent.
它无法加载Kubelet配置文件。 所有后续的错误似乎只是kubelet无法加载正确的配置文件的后果:
Flag --cgroup-driver has been deprecated, This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.
Flag --resolv-conf has been deprecated, This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.
Flag --cgroup-driver has been deprecated, This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.
Flag --resolv-conf has been deprecated, This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.
您是否检查了要尝试加载的文件/etc/kubernetes/bootstrap-kubelet.conf
?
F1120 04:53:20.230185 9604 server.go:271] failed to run Kubelet: unable to load bootstrap kubeconfig: stat /etc/kubernetes/bootstrap-kubelet.conf: no such file or directory
kubelet.service系统化单位文件/lib/systemd/system/kubelet.service中包含什么?您能附上您的问题吗?
如果主节点上的kubelet agent
无法正常启动,则无法创建/etc/kubernetes/manifests
中定义的静态Pod,并且群集中几乎所有的关键组件(包括kube-apiserver
)都将被创建。不存在。
我确实确保交换已关闭,KUBECONFIG设置正确, .kube / config正确,它正在侦听端口6443,已禁用 防火墙。
您确定它已定义为在6443
上侦听还是实际上在端口6443
上侦听? ss -ntlp | grep 6443
显示什么?
不幸的是,如果没有有关您的环境的更多信息,就无法说出在这种特定情况下确切的问题是什么。 创建环境时,您是否遵循任何特定的教程或官方文档?