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

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

Using helm

1
2
3
4
5
6
kubectl create namespace metrics

helm install metrics-server \
    stable/metrics-server \
    --version 2.9.0 \
    --namepsace metrics

Step 2 – Get the Metrics Server Status

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

1
kubectl get apiservice v1beta1.metrics.k8s.io -o json | jq '.status'

Otherwise with helm, run:

1
kubectl describe hpa

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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
{
  "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"
    }
  ]
}

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
{
  "conditions": [
    {
      "lastTransitionTime": "2022-04-13T13:27:08Z",
      "message": "all checks passed",
      "reason": "Passed",
      "status": "True",
      "type": "Available"
    }
  ]
}

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:

1
watch -n1 "kubectl get apiservice v1beta1.metrics.k8s.io -o json | jq '.status'"