GKE metric server

2/20/2021

How to re-apply GKE metric server that comes installed by default? Also will it return TOP command stats?

I tried to install and then deleted the GITHUB version of metric server and now it might have deleted some roles related to default GKE metric server. I even tried reinstalling the GitHub version but I still get error..

kubectl top pods --all-namespaces
Error from server (ServiceUnavailable): the server is currently unable to handle the request (get pods.metrics.k8s.io)
kubectl top pods --all-namespaces
Error from server (InternalError): an error on the server ("Internal Server Error: \"/apis/metrics.k8s.io/v1beta1/pods\": Unauthorized") has prevented the request from succeeding (get pods.metrics.k8s.io)

GKE has the following pods running..

metrics-server-v0.3.6-7c5cb99b6f-npgzv
gke-metrics-agent-wkg5b
-- John Doe
google-kubernetes-engine
kubernetes

1 Answer

2/20/2021

How to re-apply GKE metric server that comes installed by default?

First get name of metric server pod:

kubectl get pods --all-namespaces

Delete pod:

kubectl delete pod metrics-server-v0.3.6-547dc87f5f-sctcp -n kube-system

Since metric server is managed by Google, a new one will be reinstalled with a different pod name after deletion.

Also will it return TOP command stats? It should, for example,

kubectl top pod metrics-server-v0.3.6-547dc87f5f-sctcp --containers -n kube-system
-- dany L
Source: StackOverflow