metrics-server: Unable to fetch pod metrics & request failed - "401 Unauthorized"
Added “fixes” which reduces the errors:
git diff deploy/1.8+/metrics-server-deployment.yaml
- name: metrics-server
image: k8s.gcr.io/metrics-server-amd64:v0.3.1
+ command:
+ - /metrics-server
+ - --kubelet-insecure-tls
+ - --kubelet-preferred-address-types=InternalIP
imagePullPolicy: Always
volumeMounts:
- name: tmp-dir
➜ metrics-server git:(master) ✗ kubectl top nodes
error: metrics not available yet
➜ metrics-server git:(master) ✗ kubectl top pod
kubectl -n kube-system logs -f metrics-server-68df9fbc9f-fsvgn
E0129 00:52:04.760832 1 reststorage.go:144] unable to fetch pod metrics for pod istio-system/istio-policy-56c4579578-k5szz: no metrics known for pod
E0129 00:52:07.145193 1 reststorage.go:144] unable to fetch pod metrics for pod kube-system/kube-controller-manager-ip-10-132-10-233.us-west-2.compute.internal: no metrics known for pod
E0129 00:52:07.145211 1 reststorage.go:144] unable to fetch pod metrics for pod kube-system/coredns-784bfc9fbd-pw6hz: no metrics known for pod
E0129 00:52:07.145215 1 reststorage.go:144] unable to fetch pod metrics for pod kube-system/kube-scheduler-ip-10-132-11-28.us-west-2.compute.internal: no metrics known for pod
E0129 00:52:07.145218 1 reststorage.go:144] unable to fetch pod metrics for pod kube-system/etcd-server-ip-10-132-10-233.us-west-2.compute.internal: no metrics known for pod
E0129 00:52:07.145221 1 reststorage.go:144] unable to fetch pod metrics for pod kube-system/kube-proxy-ip-10-132-11-127.us-west-2.compute.internal: no metrics known for pod
E0129 00:52:07.145224 1 reststorage.go:144] unable to fetch pod metrics for pod kube-system/kube-controller-manager-ip-10-132-9-84.us-west-2.compute.internal: no metrics known for pod
E0129 00:52:07.145227 1 reststorage.go:144] unable to fetch pod metrics for pod kube-system/kube-apiserver-ip-10-132-9-84.us-west-2.compute.internal: no metrics known for pod
E0129 00:52:07.145230 1 reststorage.go:144] unable to fetch pod metrics for pod kube-system/etcd-server-ip-10-132-9-84.us-west-2.compute.internal: no metrics known for pod
E0129 00:52:07.145233 1 reststorage.go:144] unable to fetch pod metrics for pod kube-system/kube-scheduler-ip-10-132-10-233.us-west-2.compute.internal: no metrics known for pod
E0129 00:52:07.145236 1 reststorage.go:144] unable to fetch pod metrics for pod kube-system/kube-proxy-ip-10-132-10-233.us-west-2.compute.internal: no metrics known for pod
E0129 00:52:07.145239 1 reststorage.go:144] unable to fetch pod metrics for pod kube-system/etcd-server-events-ip-10-132-11-28.us-west-2.compute.internal: no metrics known for pod
E0129 00:52:07.145242 1 reststorage.go:144] unable to fetch pod metrics for pod kube-system/kube-proxy-ip-10-132-9-104.us-west-2.compute.internal: no metrics known for pod
E0129 00:52:07.145244 1 reststorage.go:144] unable to fetch pod metrics for pod kube-system/etcd-server-events-ip-10-132-9-84.us-west-2.compute.internal: no metrics known for pod
E0129 00:52:07.145247 1 reststorage.go:144] unable to fetch pod metrics for pod kube-system/kube-controller-manager-ip-10-132-11-28.us-west-2.compute.internal: no metrics known for pod
E0129 00:52:07.145250 1 reststorage.go:144] unable to fetch pod metrics for pod kube-system/kube-proxy-ip-10-132-11-28.us-west-2.compute.internal: no metrics known for pod
E0129 00:52:07.145254 1 reststorage.go:144] unable to fetch pod metrics for pod kube-system/kube-proxy-ip-10-132-9-84.us-west-2.compute.internal: no metrics known for pod
E0129 00:52:07.145257 1 reststorage.go:144] unable to fetch pod metrics for pod kube-system/dns-controller-7fb44784-np4bd: no metrics known for pod
E0129 00:52:07.145260 1 reststorage.go:144] unable to fetch pod metrics for pod istio-system/istio-policy-56c4579578-k5szz: no metrics known for pod
E0129 00:52:07.145263 1 reststorage.go:144] unable to fetch pod metrics for pod kube-system/kube-scheduler-ip-10-132-9-84.us-west-2.compute.internal: no metrics known for pod
E0129 00:52:07.145266 1 reststorage.go:144] unable to fetch pod metrics for pod kube-system/etcd-server-events-ip-10-132-10-233.us-west-2.compute.internal: no metrics known for pod
E0129 00:52:07.145269 1 reststorage.go:144] unable to fetch pod metrics for pod kube-system/coredns-784bfc9fbd-q8f52: no metrics known for pod
E0129 00:52:07.145272 1 reststorage.go:144] unable to fetch pod metrics for pod istio-system/istio-grafana-post-install-cwx6n: no metrics known for pod
E0129 00:52:07.145277 1 reststorage.go:144] unable to fetch pod metrics for pod kube-system/kube-apiserver-ip-10-132-10-233.us-west-2.compute.internal: no metrics known for pod
E0129 00:52:07.145296 1 reststorage.go:144] unable to fetch pod metrics for pod kube-system/kube-apiserver-ip-10-132-11-28.us-west-2.compute.internal: no metrics known for pod
E0129 00:52:07.145305 1 reststorage.go:144] unable to fetch pod metrics for pod istio-system/istio-cleanup-secrets-56bjj: no metrics known for pod
E0129 00:52:07.145310 1 reststorage.go:144] unable to fetch pod metrics for pod kube-system/tiller-deploy-57f988f854-zjftk: no metrics known for pod
E0129 00:52:07.145318 1 reststorage.go:144] unable to fetch pod metrics for pod istio-system/istio-security-post-install-98mvv: no metrics known for pod
E0129 00:52:07.145322 1 reststorage.go:144] unable to fetch pod metrics for pod kube-system/metrics-server-68df9fbc9f-fsvgn: no metrics known for pod
E0129 00:52:07.145325 1 reststorage.go:144] unable to fetch pod metrics for pod kube-system/kube-proxy-ip-10-132-10-63.us-west-2.compute.internal: no metrics known for pod
E0129 00:52:07.145329 1 reststorage.go:144] unable to fetch pod metrics for pod kube-system/etcd-server-ip-10-132-11-28.us-west-2.compute.internal: no metrics known for pod
E0129 00:52:34.895839 1 reststorage.go:144] unable to fetch pod metrics for pod istio-system/istio-policy-56c4579578-k5szz: no metrics known for pod
E0129 00:52:48.373899 1 manager.go:102] unable to fully collect metrics: [unable to fully scrape metrics from source kubelet_summary:ip-10-132-9-84.us-west-2.compute.internal: unable to fetch metrics from Kubelet ip-10-132-9-84.us-west-2.compute.internal (10.132.9.84): request failed - "401 Unauthorized", response: "Unauthorized", unable to fully scrape metrics from source kubelet_summary:ip-10-132-10-63.us-west-2.compute.internal: unable to fetch metrics from Kubelet ip-10-132-10-63.us-west-2.compute.internal (10.132.10.63): request failed - "401 Unauthorized", response: "Unauthorized", unable to fully scrape metrics from source kubelet_summary:ip-10-132-11-28.us-west-2.compute.internal: unable to fetch metrics from Kubelet ip-10-132-11-28.us-west-2.compute.internal (10.132.11.28): request failed - "401 Unauthorized", response: "Unauthorized", unable to fully scrape metrics from source kubelet_summary:ip-10-132-9-104.us-west-2.compute.internal: unable to fetch metrics from Kubelet ip-10-132-9-104.us-west-2.compute.internal (10.132.9.104): request failed - "401 Unauthorized", response: "Unauthorized", unable to fully scrape metrics from source kubelet_summary:ip-10-132-11-127.us-west-2.compute.internal: unable to fetch metrics from Kubelet ip-10-132-11-127.us-west-2.compute.internal (10.132.11.127): request failed - "401 Unauthorized", response: "Unauthorized", unable to fully scrape metrics from source kubelet_summary:ip-10-132-10-233.us-west-2.compute.internal: unable to fetch metrics from Kubelet ip-10-132-10-233.us-west-2.compute.internal (10.132.10.233): request failed - "401 Unauthorized", response: "Unauthorized"]
E0129 00:53:05.099637 1 reststorage.go:144] unable to fetch pod metrics for pod istio-system/istio-policy-56c4579578-k5szz: no metrics known for pod
E0129 00:53:35.216151 1 reststorage.go:144] unable to fetch pod metrics for pod istio-system/istio-policy-56c4579578-k5szz: no metrics known for pod
Is there a version that works (ie one of the 200 forks)? I’ve used k8s 1.10 and 1.11 on AWS via Kops.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 17
- Comments: 37 (3 by maintainers)
Commits related to this issue
- Add ClusterRoleBinding to fix kubelet-api RBAC See https://github.com/kubernetes-incubator/metrics-server/issues/212#issuecomment-459321884 — committed to mattkelly/metrics-server by mattkelly 5 years ago
Metrics server may fail to authenticate if kubelet is running with
--anonymous-auth=false
flag. Passing--authentication-token-webhook=true
and--authorization-mode=Webhook
flags to kubelet can fix this. kops config for kubelet:This might break authorization for kubelet-api user if
ClusterRoleBinding
is not created withsystem:kubelet-api-admin
. Which can be fixed by creating theClusterRoleBinding
:@mabushey I believe using “args” is slightly better than “command”, it respects the entrypoint.
I changed from using “args” to “commands” and I don’t see the
401 Unauthorized
now. However,kubectl logs -f metrics-server... -n kube-system
still shows “no metrics known for pod”:kubectl top nodes
show valid data with resource percentage.kubectl top pod
does not have any percentage at all.@zahid0 Oh, no. My script has a mistake, should run kops rolling-update but I ran kops update. Now it works.
I can get the metrics. Thanks a lot for your help 😃
@vinhnglx
kops rolling-update
is required afterterraform apply
. https://github.com/kubernetes/kops/blob/master/docs/terraform.md#caveats@zoltan-fedor @zhanghan12 I had similar issue (though
kubectl top pods
still doesn’t show % for me), but basically HPA works now.My setup is kops 1.13 with k8s 1.13.5 & istio
I have setup similar to other comments:
And running metrics-server as:
What really helped me is able to debug the issue by setting the log level…
And i found this article by rancher
Following the guide and creating the additional ClusterRole binding for
system:anonymous
user seem to have fixed the issue for me@zahid0 I’m using Kops to install Kubernetes with vpc, private subnets, and calico CNI for networking. I’m not able to ssh to the instance to check the kubelet.
But I already set the
authentication-token-webhook=true
andauthorization-mode=Webhook
usingkops edit cluster
commandAnd it still shows the
401 Unauthorized
Here is my working config: kops cluster spec for kubelet.
Metrics server yaml:
role.yaml from https://github.com/kubernetes/kops/issues/5706 and
I have created metric server with below deployment and addedd kubelet config in kops but I still get 401
Logs:
this works thank you very much. saved some prod time 😃 https://github.com/kubernetes-sigs/metrics-server/issues/212#issuecomment-459321884
@vinhnglx do you mind showing the output of
kops update cluster
andkops rolling-update cluster
…@vinhnglx could you check the arguments passed to
kubelet
on one of the nodes? If you run kubelet usingsystemd
, then ssh to instance and runsudo systemctl status kubelet
. Make sure--authentication-token-webhook=true
and--authorization-mode=Webhook
flags are passed. Checkingkubectl
logs may also help (runjournalctl -u kubelet
on the node for logs).thanks @rajeshkodali .
I still hit the error “401 Unauthorized”