Skip to content

How to Deploy a Metrics Server in Kubernetes

If you would like to deploy a Metrics Server in Kubernetes, then you first need to create a namespace for it to live it, followed by installing the actual metrics server.

Step 1 – Install the Metrics Server

Using kubectl

kubectl apply -f
Code language: Bash (bash)

Using helm

kubectl create namespace metrics helm install metrics-server \ stable/metrics-server \ --version 2.9.0 \ --namepsace metrics
Code language: Bash (bash)

Step 2 – Get the Metrics Server Status

If you used kubectl above, then you should be able to run:

kubectl get apiservice -o json | jq '.status'
Code language: Bash (bash)

Otherwise with helm, run:

kubectl describe hpa
Code language: Bash (bash)

Step 3 – Verifying the Metrics Server Setup

If you get the following output, then it just means the server is not ready yet, wait a moment longer:

{ "conditions": [ { "lastTransitionTime": "2022-04-13T13:26:45Z", "message": "endpoints for service/metrics-server in \"kube-system\" have no addresses with port name \"https\"", "reason": "MissingEndpoints", "status": "False", "type": "Available" } ] }
Code language: JSON / JSON with Comments (json)

When the Metrics Server is ready, you will get a response as follows:

{ "conditions": [ { "lastTransitionTime": "2022-04-13T13:27:08Z", "message": "all checks passed", "reason": "Passed", "status": "True", "type": "Available" } ] }
Code language: JSON / JSON with Comments (json)

Step 4 – A tip to be alerted when ready

You can always watch the above command instead of running the same command over and over above, while waiting for the server to become available:

watch -n1 "kubectl get apiservice -o json | jq '.status'"
Code language: Bash (bash)

See also  How to Presign an S3 URL in AWS using AWS CLI
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x