我正在运行命令kubectl top nodes并收到错误:
node@kubemaster:~/Desktop/metric$ kubectl top nodes
Error from server (ServiceUnavailable): the server is currently unable to handle the request (get nodes.metrics.k8s.io)
度量服务器pod正在使用以下参数运行:
command:
- /metrics-server
- --metric-resolution=30s
- --requestheader-allowed-names=aggregator
- --kubelet-insecure-tls
- --kubelet-preferred-address-types=InternalIP,Hostname,InternalDNS,ExternalDNS,ExternalIP
我得到的大部分答案是上述参数,仍然得到错误
E0601 18:33:22.012798 1 manager.go:111] unable to fully collect metrics: [unable to fully scrape metrics from source kubelet_summary:kubemaster: unable to fetch metrics from Kubelet kubemaster (192.168.56.30): Get https://192.168.56.30:10250/stats/summary?only_cpu_and_memory=true: context deadline exceeded, unable to fully scrape metrics from source kubelet_summary:kubenode1: unable to fetch metrics from Kubelet kubenode1 (192.168.56.31): Get https://192.168.56.31:10250/stats/summary?only_cpu_and_memory=true: dial tcp 192.168.56.31:10250: i/o timeout]
我已使用以下工具部署度量服务器:
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/download/v0.3.6/components.yaml
我错过了什么?使用Calico进行Pod联网
在度量服务器的github页面上的FAQ下:
[Calico] Check whether the value of CALICO_IPV4POOL_CIDR in the calico.yaml conflicts with the local physical network segment. The default: 192.168.0.0/16.
可能是这个原因吧。谁能给我解释一下。
我已使用以下设置Calico:库贝特尔应用-f https://docs.projectcalico.org/v3.14/manifests/calico.yaml
My Node Ips are : 192.168.56.30 / 192.168.56.31 / 192.168.56.32
I have initiated the cluster with --pod-network-cidr=20.96.0.0/12. So my pods Ip are 20.96.205.192 and so on.
在apiserver日志中也有记录
E0601 19:29:59.362627 1 available_controller.go:420] v1beta1.metrics.k8s.io failed with: failing or missing response from https://10.100.152.145:443/apis/metrics.k8s.io/v1beta1: Get https://10.100.152.145:443/apis/metrics.k8s.io/v1beta1: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
where 10.100.152.145 is IP of service/metrics-server(ClusterIP)
Surprisingly it works on another cluster with Node Ip in 172.16.0.0 range. Rest everything is same. Setup using kudeadm, Calico, same pod cidr
4条答案
按热度按时间sq1bmfud1#
在我编辑metrics-server部署yaml配置以包含DNS策略之后,它开始工作。
主机网络:真实
请参阅以下链接:https://www.linuxsysadmins.com/service-unavailable-kubernetes-metrics/
q9yhzks02#
Default value of Calico net is 192.168.0.0/16 There is a comment in yaml file:
启动时创建的默认IPv4池(如果不存在)。将从此范围中选择Pod IP。安装后更改此值将不起作用。此值应在
--cluster-cidr
范围内。So, its better use different one if your home network is contained in 192.168.0.0/16.
另外,如果你使用kubeadm,你可以在k8s中检查你的cidr:
也可以使用kubectl:
Default one in kubernetes "selfhosted" is 10.96.0.0/12
tjrkku2a3#
我在Docker桌面上运行度量时遇到了同样的问题,我按照@suren的答案操作,结果成功了。默认配置是:
我就改成:
67up9zun4#
我在内部部署k8s v1.26(cni=calico)中遇到了同样的问题。我认为这个问题是由于Metric-Server版本(v0.6)造成的。我通过应用Metric-Server v5.0.2解决了这个问题
1-从官方来源下载this Yaml文件
2-在-args部分下面添加(- --kubelet-unsecure-tls=true)
3-应用Yarn
享受;)