Skip to content

Instantly share code, notes, and snippets.

@NileshGule
Last active October 2, 2024 21:21
Show Gist options
  • Save NileshGule/8f772cf04ea6ae9c76d3f3e9186165c2 to your computer and use it in GitHub Desktop.
Save NileshGule/8f772cf04ea6ae9c76d3f3e9186165c2 to your computer and use it in GitHub Desktop.
gist to update kuberentes metrics server deployment

deploy metrics server


kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml

edit metrics server deployment by adding command


k -n kube-system edit deploy metrics-server

containers:
- args:
- --cert-dir=/tmp
- --secure-port=4443
- --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
- --kubelet-use-node-status-port
- --metric-resolution=15s
command:
- /metrics-server
- --kubelet-insecure-tls
- --kubelet-preferred-address-types=InternalIP
@NileshGule
Copy link
Author

anyone know how to fix this error ? @NileshGule Error from server (ServiceUnavailable): the server is currently unable to handle the request (get nodes.metrics.k8s.io)

And this is the result what I tried to log kubectl logs -n kube-system deploy/metrics-server

I1004 02:20:09.250465       1 serving.go:342] Generated self-signed cert (/tmp/apiserver.crt, /tmp/apiserver.key)
I1004 02:20:10.741119       1 requestheader_controller.go:169] Starting RequestHeaderAuthRequestController
I1004 02:20:10.741164       1 shared_informer.go:240] Waiting for caches to sync for RequestHeaderAuthRequestController
I1004 02:20:10.741156       1 configmap_cafile_content.go:201] "Starting controller" name="client-ca::kube-system::extension-apiserver-authentication::client-ca-file"
I1004 02:20:10.741235       1 configmap_cafile_content.go:201] "Starting controller" name="client-ca::kube-system::extension-apiserver-authentication::requestheader-client-ca-file"
I1004 02:20:10.741296       1 shared_informer.go:240] Waiting for caches to sync for client-ca::kube-system::extension-apiserver-authentication::requestheader-client-ca-file
I1004 02:20:10.741276       1 shared_informer.go:240] Waiting for caches to sync for client-ca::kube-system::extension-apiserver-authentication::client-ca-file
I1004 02:20:10.742445       1 dynamic_serving_content.go:131] "Starting controller" name="serving-cert::/tmp/apiserver.crt::/tmp/apiserver.key"
I1004 02:20:10.743275       1 secure_serving.go:266] Serving securely on [::]:4443
I1004 02:20:10.743512       1 tlsconfig.go:240] "Starting DynamicServingCertificateController"
W1004 02:20:10.743550       1 shared_informer.go:372] The sharedIndexInformer has started, run more than once is not allowed
I1004 02:20:10.841637       1 shared_informer.go:247] Caches are synced for client-ca::kube-system::extension-apiserver-authentication::client-ca-file
I1004 02:20:10.841656       1 shared_informer.go:247] Caches are synced for client-ca::kube-system::extension-apiserver-authentication::requestheader-client-ca-file
I1004 02:20:10.841798       1 shared_informer.go:247] Caches are synced for RequestHeaderAuthRequestController

I don't understand what is this error

The sharedIndexInformer has started, run more than once is not allowed

Is your metrics-server pods up and running?

@WasimAhmad
Copy link

WasimAhmad commented Oct 21, 2022

download yaml file and add command session then apply
- args:
- --cert-dir=/tmp
- --secure-port=4443
- --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
- --kubelet-use-node-status-port
- --metric-resolution=15s
command:
- /metrics-server
- --kubelet-insecure-tls
- --kubelet-preferred-address-types=InternalIP

@bb-vikrantshetty
Copy link

@NileshGule I am still getting the same error
Readiness probe failed: HTTP probe failed with statuscode: 500

@bobymark
Copy link

Use this link to resolve https://stackoverflow.com/questions/71843068/metrics-server-is-currently-unable-to-handle-the-request
kubectl edit deployments.apps -n kube-system metrics-server
Resolved by editing the deployment yaml files and adding the hostNetwork: true after the dnsPolicy: ClusterFirst
save the file and wait for a min and then check the kubectl top no

@Thachana
Copy link

you made it .

Copy link

ghost commented Aug 29, 2023

everything worked perfectly but when I proceeded with kubectl top nodes it showed the error: Metrics API not available
Normal Created 3m28s kubelet Created container metrics-server
Normal Started 3m28s kubelet Started container metrics-server
@NileshGule @WasimAhmad

@ToneCode
Copy link

Awesome, it works for me!

@Asfawh
Copy link

Asfawh commented Oct 28, 2023

Thank you for these!

@henrique-alexandre
Copy link

Thank you very VERY much for this!

@theten52
Copy link

Thanks so much for this! it works for me!

@irtazakhalid24
Copy link

Hi, Can someone let me know the location of this file kubernetes-metrics-server.yaml

@tbernacchi
Copy link

@tbernacchi
Copy link

@NileshGule I've follow the exactly steps provided and I still got no lucky. Any ideas?

@tbernacchi
Copy link

same for me @ghost

@jmutai
Copy link

jmutai commented Aug 2, 2024

For anyone getting the error i figured it out, see article - https://computingforgeeks.com/fix-error-metrics-api-not-available-in-kubernetes/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment