# Install metrics-server on Kubernetes (Digital Ocean)

# How to install metric server on DOKS.

🗓 February 5, 2020 | 👱 By: Hugh

If you're trying to setup Horizontal Pod Scaling on a Digital Ocean Kubernetes cluster, you'll quickly find you need metrics-server installed to support it. This is because to scale, the system needs to get metrics on CPU utilization of each of the pods in a specific deployment.

So. How do you install metric-server on Kubernetes? According to the repo README it is simple:

git clone https://github.com/kubernetes-sigs/metrics-server.git
cd metrics-server
kubectl apply -f deploy/1.8+/

Unfortunately, however, it doesn't work. I generally run a command like this to see if it is working:

kubectl top pod <pod-name> -n <namespace>

So, how can you fix it?

Based on the advice in this GitHub issue, we need to add an extra line to the file deploy/1.8+/metrics-server-deployment.yaml

Add the following line to the container args:

- --kubelet-preferred-address-types=InternalIP

It should look something like this:

      - name: metrics-server
        image: k8s.gcr.io/metrics-server-amd64:v0.3.6
          - --cert-dir=/tmp
          - --secure-port=4443
          - --kubelet-preferred-address-types=InternalIP
        - name: main-port
          containerPort: 4443
          protocol: TCP

Re-apply that file

kubectl apply -f metrics-server-deployment.yaml

Wait a few seconds for the pods to pick up the changes, then you should be able to inspect the CPU and memory usage of pods!

kubectl top pod example-website-7564785cc9-ftfqz -n website-1 
NAME                            CPU(cores)   MEMORY(bytes)   
doks-example-7564785cc9-ftfqz   0m           3Mi

I'll link to a post on setting up Horizontal Pod Autoscaling soon! Apologies in advance if I forget.