Kubernetes dashboard: 获取 https://10.96.0.1:443/version: dial tcp 10.96.0.1:443: i/o timeout

Kubernetes dashboard: Get https://10.96.0.1:443/version: dial tcp 10.96.0.1:443: i/o timeout

我在 vagrant (1.14.0) 中有一个 Kubernetes 集群并安装了 calico。

我已经安装了 kubernetes 仪表板。当我使用 kubectl proxy 访问仪表板时:

Error: 'dial tcp 192.168.1.4:8443: connect: connection refused'
Trying to reach: 'https://192.168.1.4:8443/'

这是我的 pods(仪表板频繁重启):

$ kubectl get pods -n kube-system
NAME                                       READY   STATUS    RESTARTS   AGE
calico-etcd-cj928                          1/1     Running   0          11m
calico-node-4fnb6                          1/1     Running   0          18m
calico-node-qjv7t                          1/1     Running   0          20m
calico-policy-controller-b9b6749c6-29c44   1/1     Running   1          11m
coredns-fb8b8dccf-jjbhk                    1/1     Running   0          20m
coredns-fb8b8dccf-jrc2l                    1/1     Running   0          20m
etcd-k8s-master                            1/1     Running   0          19m
kube-apiserver-k8s-master                  1/1     Running   0          19m
kube-controller-manager-k8s-master         1/1     Running   0          19m
kube-proxy-8mrrr                           1/1     Running   0          18m
kube-proxy-cdsr9                           1/1     Running   0          20m
kube-scheduler-k8s-master                  1/1     Running   0          19m
kubernetes-dashboard-5f7b999d65-nnztw      1/1     Running   3          2m11s

dasbhoard pod 的日志:

2019/03/30 14:36:21 Error while initializing connection to Kubernetes apiserver. This most likely means that the cluster is misconfigured (e.g., it has invalid apiserver certificates or service account's configuration) or the --apiserver-host param points to a server that does not exist. Reason: Get https://10.96.0.1:443/version: dial tcp 10.96.0.1:443: i/o timeout
Refer to our FAQ and wiki pages for more information: https://github.com/kubernetes/dashboard/wiki/FAQ

我可以从主节点和节点远程登录到 10.96.0.1:443。

什么配置错误?集群的其余部分似乎工作正常,尽管我在 kubelet 中看到了这个日志:

failed to load Kubelet config file /var/lib/kubelet/config.yaml, error failed to read kubelet config file "/var/lib/kubelet/config.yaml"

kubelet 似乎 运行 在 master 上很好。 集群是使用以下命令创建的:

kubeadm init --apiserver-advertise-address="192.168.50.10" --apiserver-cert-extra-sans="192.168.50.10" --node-name k8s-master --pod-network-cidr=192.168.0.0/16

您应该在 /etc/hosts

中定义您的主机名
#hostname
YOUR_HOSTNAME
#nano /etc/hosts
YOUR_IP HOSTNAME

如果您在主机中设置了您的主机名但它不起作用,请尝试

# systemctl stop kubelet
# systemctl stop docker
# iptables --flush
# iptables -tnat --flush
# systemctl start kubelet
# systemctl start docker

并且您应该在加入工作节点之前安装仪表板

禁用防火墙

你可以查看你的空闲内存。

从 kubeadm init 命令中排除 --node-name 参数

试试这个命令

kubeadm init --apiserver-advertise-address=$(hostname -i) --apiserver-cert-extra-sans="192.168.50.10" --pod-network-cidr=192.168.0.0/16

对我来说,问题是我需要创建一个允许 Egress 流量到 kubernetes 的 NetworkPolicy API