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
Code language: Bash (bash)kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/download/v0.5.0/components.yaml
Using helm
Code language: Bash (bash)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:
kubectl get apiservice v1beta1.metrics.k8s.io -o json | jq '.status'
Code language: Bash (bash)
Otherwise with helm
, run:
Code language: Bash (bash)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:
{
"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 v1beta1.metrics.k8s.io -o json | jq '.status'"
Code language: Bash (bash)