由于拨打TCP 127.0.0.1:10248而导致Kubernetes kubeadm初始化失败:connect:连接被拒绝

时间:2019-02-16 22:24:30

标签: kubernetes vsphere kubeadm

我正在尝试在vSphere私有云中设置一个非常简单的2节点k8s 1.13.3集群。 VM正在运行Ubuntu 18.04。出于测试目的,防火墙已关闭。但是由于拒绝连接,初始化失败。除了端口被阻塞以外,还有其他可能导致此问题的原因吗?我是k8s的新手,正在尝试把我的头缠在这一切上。

我已将vsphere.conf放在/ etc / kubernetes /中,如本要点所示。 https://gist.github.com/spstratis/0395073ac3ba6dc24349582b43894a77

我还创建了一个配置文件以指向运行kubeadm init的时间。这是其内容的示例。 https://gist.github.com/spstratis/086f08a1a4033138a0c42f80aef5ab40

当我跑步时 sudo kubeadm init --config /etc/kubernetes/kubeadminitmaster.yaml 它超时并显示以下错误。

[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 127.0.0.1:10248: connect: connection refused.

检查sudo systemctl status kubelet显示kubelet正在运行。我暂时关闭了主VM上的防火墙以测试目的,以便可以验证集群是否会自我引导。

   Loaded: loaded (/lib/systemd/system/kubelet.service; enabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/kubelet.service.d
           └─10-kubeadm.conf
   Active: active (running) since Sat 2019-02-16 18:09:58 UTC; 24s ago
     Docs: https://kubernetes.io/docs/home/
 Main PID: 16471 (kubelet)
    Tasks: 18 (limit: 4704)
   CGroup: /system.slice/kubelet.service
           └─16471 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/kubelet/config.yaml --cloud-config=/etc/kubernetes/vsphere.conf --cloud-provider=vsphere --cgroup-driver=systemd --network-plugin=cni --pod-i

下面还有一些其他日志,显示与https://192.168.0.12:6443/的连接被拒绝。所有这些似乎导致kubelet失败并阻止了初始化过程的完成。

    Feb 16 18:10:22 k8s-master-1 kubelet[16471]: E0216 18:10:22.633721   16471 kubelet.go:2266] node "k8s-master-1" not found
    Feb 16 18:10:22 k8s-master-1 kubelet[16471]: E0216 18:10:22.668213   16471 reflector.go:134] k8s.io/kubernetes/pkg/kubelet/kubelet.go:453: Failed to list *v1.Node: Get https://192.168.0.12:6443/api/v1/nodes?fieldSelector=metadata.name%3Dk8s-master-1&limit=500&resourceVersion=0: dial tcp 192.168.0.1
Feb 16 18:10:22 k8s-master-1 kubelet[16471]: E0216 18:10:22.669283   16471 reflector.go:134] k8s.io/kubernetes/pkg/kubelet/kubelet.go:444: Failed to list *v1.Service: Get https://192.168.0.12:6443/api/v1/services?limit=500&resourceVersion=0: dial tcp 192.168.0.12:6443: connect: connection refused
    Feb 16 18:10:22 k8s-master-1 kubelet[16471]: E0216 18:10:22.670479   16471 reflector.go:134] k8s.io/kubernetes/pkg/kubelet/config/apiserver.go:47: Failed to list *v1.Pod: Get https://192.168.0.12:6443/api/v1/pods?fieldSelector=spec.nodeName%3Dk8s-master-1&limit=500&resourceVersion=0: dial tcp 192.1
    Feb 16 18:10:22 k8s-master-1 kubelet[16471]: E0216 18:10:22.734005   16471 kubelet.go:2266] node "k8s-master-1" not found

1 个答案:

答案 0 :(得分:2)

您不能使用bootstrap-kubeconfig来初始化主节点的kubelet,因为(正如您所遇到的那样)它没有api服务器可以联系以生成其私钥和证书。赶上22。我大约80%的确信从kubelet args中删除--bootstrap-kubeconfig将有助于解决这种情况。我会期望,该kubelet已经在/var/lib/kubelet/pki中具有其密钥和证书,因此也可能值得检查。

此外,假设您正在使用/etc/kubernetes/manifests目录运行apiserver和controllermanager,请确保/var/lib/kubelet/config.yaml中的staticPodPath:指向正确的目录。不太可能是问题所在,但是检查起来非常便宜。