Unable to get pod metrics -Kubernetes

11/29/2018

I'm not able to get the metrics for the pod. The result for "describe hpa " command is shown below. I can not autoscale!!!

result for describe hpa command my kubernetes version and result for "get hpa" is given in this screenshot below. enter image description here Please help me to autoscale my app. I used this instruction to install hpa https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#run-expose-php-apache-server]3. I'm using digital ocean cloud to run my cluster.Help me install anything to get metrics so I can use that to hpa.

-- AATHITH RAJENDRAN
autoscaling
digital-ocean
horizontal-scaling
kubernetes
kubernetes-pod

1 Answer

1/9/2019

I was able to recreate this issue.

Digital Ocean does not support Cluster Auto scaling as mentioned here. But it seems that HPA should work, as it scales pods.

I was able to work with this and get the HPA to work. Note that I did not spend a significant amount of time on this, so I am not yet aware if there are any issues later on. My goal was to make hpa scale and this was successful.

First install the Metrics server as the Heapster is deprecated. I did that by git clone and then kubectl create -f deploy/1.8+/.

Next find the metrics server deployment and edit it:

kubectl edit deployment metrics-server -n kube-system

Under spec: ->containers: add following metrics:

spec:
      containers:
      - command:
        - /metrics-server
        - --kubelet-insecure-tls
        - --kubelet-preferred-address-types=InternalIP
        - --logtostderr

Wait few minutes, when you will call kubectl get hpa you will see that under TARGETS<unknown>/50%changes to 0%/50% you are ready to generate the load and scale the pods. After you stop the load, the hpa will slowly start removing the pods.

UPDATE:

you probably missed a dash. It should look like this.

spec:
      containers:
      - command:
        - /metrics-server
        - --kubelet-insecure-tls
        - --kubelet-preferred-address-types=InternalIP
        - --logtostderr
        image: k8s.gcr.io/metrics-server-amd64:v0.3.1

Delete the dash that was in front of "image".

Hope this helps.

-- aurelius
Source: StackOverflow