not able to run hpa, get metrics to api metrics

3/18/2019

I am trying to run horizontal pod autoscaler in kubernetes, want to auto scale my pods based on cpu default metrics. For that I installed metrics server after that I can see metrics - metrics.k8s.io/v1beta1 (kubectl api-versions). Then I tried deploying prometheus-operator. But upon runnning kubectl top node/pod - error I am getting is

error: Metrics not available for pod default/web-deployment-658cd556f8-ztf6c, age: 35m23.264812635s" and "error: metrics not available yet"

Do I need to run heapster?

-- batman
heapster
kubernetes
prometheus

2 Answers

4/10/2019

@batman, as you said enabling minikube metrics-server add-on is enough in case of using minikube.

In general case, if using metrics-server you edited the metrics server deployment by running: kubectl edit deployment metrics-server -n kube-system

Under spec: -> containers: add following flag:

spec:
      containers:
      - command:
        - /metrics-server
        - --kubelet-insecure-tls

As described on metrics-server github:

--kubelet-insecure-tls: skip verifying Kubelet CA certificates. Not recommended for production usage, but can be useful in test clusters with self-signed Kubelet serving certificates.

Here you can find tutorial describing HPA using custom metrics and Prometheus.

-- MWZ
Source: StackOverflow

3/18/2019

In minikube, we have to enable metrics-server add-on.

minikube addons list

minikube addons enable metrics-server

Then create hpa, deployment and boom!!

Anyone has done autoscaling based on custom metrics? like based on no. of http requests?

-- batman
Source: StackOverflow