【发布时间】:2021-11-12 04:32:03
【问题描述】:
我在 2 个 raspberry pi 4 中部署了一个 k3s 集群。一个作为 master,另一个作为 worker,使用脚本 k3s 提供以下选项:
对于主节点:
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC='server --bind-address 192.168.1.113 (which is the master node ip)' sh -
到代理节点:
curl -sfL https://get.k3s.io | \
K3S_URL=https://192.168.1.113:6443 \
K3S_TOKEN=<master-token> \
INSTALL_K3S_EXEC='agent' sh-
似乎一切正常,但 kubectl top nodes 返回以下内容:
NAME CPU(cores) CPU% MEMORY(bytes) MEMORY%
k3s-master 137m 3% 1285Mi 33%
k3s-node-01 <unknown> <unknown> <unknown> <unknown>
我也尝试部署k8s仪表板,根据the docs中写的内容,但它无法工作,因为它无法访问指标服务器并出现超时错误:
"error trying to reach service: dial tcp 10.42.1.11:8443: i/o timeout"
我在 pod 日志中看到很多错误:
2021/09/17 09:24:06 Metric client health check failed: the server is currently unable to handle the request (get services dashboard-metrics-scraper). Retrying in 30 seconds.
2021/09/17 09:25:06 Metric client health check failed: the server is currently unable to handle the request (get services dashboard-metrics-scraper). Retrying in 30 seconds.
2021/09/17 09:26:06 Metric client health check failed: the server is currently unable to handle the request (get services dashboard-metrics-scraper). Retrying in 30 seconds.
2021/09/17 09:27:06 Metric client health check failed: the server is currently unable to handle the request (get services dashboard-metrics-scraper). Retrying in 30 seconds.
来自metrics-server pod 的日志:
elet_summary:k3s-node-01: unable to fetch metrics from Kubelet k3s-node-01 (k3s-node-01): Get https://k3s-node-01:10250/stats/summary?only_cpu_and_memory=true: dial tcp 192.168.1.106:10250: connect: no route to host
E0917 14:03:24.767949 1 manager.go:111] unable to fully collect metrics: unable to fully scrape metrics from source kubelet_summary:k3s-node-01: unable to fetch metrics from Kubelet k3s-node-01 (k3s-node-01): Get https://k3s-node-01:10250/stats/summary?only_cpu_and_memory=true: dial tcp 192.168.1.106:10250: connect: no route to host
E0917 14:04:24.767960 1 manager.go:111] unable to fully collect metrics: unable to fully scrape metrics from source kubelet_summary:k3s-node-01: unable to fetch metrics from Kubelet k3s-node-01 (k3s-node-01): Get https://k3s-node-01:10250/stats/summary?only_cpu_and_memory=true: dial tcp 192.168.1.106:10250: connect: no route to host
【问题讨论】:
-
我无法重现这种行为(不是在树莓上,而是在 ubuntu 虚拟机上),经过一段时间后,工作节点也获得了指标。我看到您的安装命令与documentation says 有点不同。您也可以尝试通过
k3s kubectl rollout restart deploy metrics-server -n kube-system+ 检查metrics-serverpod 中的日志来重新启动指标服务器。 -
谢谢,从 metrics-server pod 添加了日志,它看起来像是在查看节点的错误 IP?
-
网络设置有问题。您可以通过
hostnameping 您的工作节点吗?检查/etc/hosts是否有条目或尝试使用正确的IP添加它。 -
嗯,这是一个不同的错误。这次看起来您的网络看到了另一台主机。 1 - 您可以从系统中 ping/curl 另一台主机吗?它有效吗? 2 - 检查工作节点上的
sudo netstat -tulpn,它是否监听 10250? 3 - 主机上有防火墙吗?如果是这样,请将其禁用以进行测试。 -
我重新配置了集群,现在一切似乎都正常了。部分问题是 ntp 无法正常工作,所以我遇到了证书问题。
标签: kubernetes k3s metrics-server