【问题标题】:k3s - Metrics server doesn't work for worker nodesk3s - 指标服务器不适用于工作节点
【发布时间】: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-server pod 中的日志来重新启动指标服务器。
  • 谢谢,从 metrics-server pod 添加了日志,它看起来像是在查看节点的错误 IP?
  • 网络设置有问题。您可以通过hostname ping 您的工作节点吗?检查/etc/hosts是否有条目或尝试使用正确的IP添加它。
  • 嗯,这是一个不同的错误。这次看起来您的网络看到了另一台主机。 1 - 您可以从系统中 ping/curl 另一台主机吗?它有效吗? 2 - 检查工作节点上的sudo netstat -tulpn,它是否监听 10250? 3 - 主机上有防火墙吗?如果是这样,请将其禁用以进行测试。
  • 我重新配置了集群,现在一切似乎都正常了。部分问题是 ntp 无法正常工作,所以我遇到了证书问题。

标签: kubernetes k3s metrics-server


【解决方案1】:

将其移出 cmets 以获得更好的可见性。


创建小型集群后,我无法重现此行为,metrics-server 在两个节点上都运行良好,kubectl top nodes 显示了有关两个可用节点的信息和指标(认为开始收集指标需要一些时间)。

这会导致故障排除步骤为什么它不起作用。检查metrics-server 日志是解决此问题的最有效方法:

$ kubectl logs metrics-server-58b44df574-2n9dn -n kube-system

根据日志,将有不同的步骤继续,例如在上面的 cmets 中:

  • 首先是no route to host,它与网络有关,无法解析主机名
  • 然后是i/o timeout,表示路由存在,但服务没有响应。这可能是由于防火墙阻止了某些端口/源,kubelet 未运行(侦听端口10250)或出现在 OP 中,ntp 存在问题,影响了证书和连接。李>
  • 错误在其他情况下可能有所不同,重要的是找到错误并根据它进一步排除故障。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多