0

I tried solutions from this link but failed to get CPU usage (it still show <unknown>).

Below are steps that I performed:

  1. Clone the metrics-server github repo: git clone https://github.com/kubernetes-incubator/metrics-server.git

  2. Add below lines under "imagePullPolicy" in metrics-server-deployment.yaml:

  command:
  - /metrics-server
  - --metric-resolution=30s
  - --kubelet-insecure-tls
  - --kubelet-preferred-address-types=InternalIP
  1. Go into directory cd deploy/1.8+ and run following yaml files:

    • kubectl apply -f aggregated-metrics-reader.yaml
    • kubectl apply -f auth-reader.yaml
    • kubectl apply -f auth-delegator.yaml
    • kubectl apply -f metrics-apiservice.yaml
    • kubectl apply -f resource-reader.yaml
    • kubectl apply -f metrics-server-deployment.yaml
    • kubectl apply -f metrics-server-service.yaml

4.a) Run sample pod:

kubectl run --generator=run-pod/v1 php-apache --image=k8s.gcr.io/hpa-example --requests=cpu=200m --expose --port=80

  1. Faced error when create HPA:

    kubectl autoscale deployment php-apache --cpu-percent=50 --min=1 --max=10 horizontalpodautoscaler.autoscaling/php-apache autoscaled

    error: there is no need to specify a resource type as a separate argument when passing arguments in resource/name form (e.g. 'kubectl get resource/' instead of 'kubectl get resource resource/'

4.b) Run my pod and recreate HPA

--> still display in CPU usage when "kubectl get hpa"

How can I set to retrieve CPU usage properly?

Provide more information for HPA below:

Output of HPA

Describe of HPA

DaiKeung
  • 1,077
  • 1
  • 19
  • 38
  • Could you please add output of `kubectl get hpa` and `kubectl decribe hpa ` – Prafull Ladha Jan 30 '19 at 05:24
  • Added outputs already, please help to have a look, thanks – DaiKeung Jan 30 '19 at 05:38
  • I changed 4.a) to "kubectl run php-apache --image=k8s.gcr.io/hpa-example --requests=cpu=200m --expose --port=80" then have Deployment in Kubernetes, but still cannot get CPU usage. – DaiKeung Jan 30 '19 at 07:30
  • Your HPA is still using heapster, rather than metrics server to get the CPU metrics and hence the issue. – Prafull Ladha Jan 30 '19 at 07:32
  • How can I set to use metrics-server ? – DaiKeung Jan 30 '19 at 07:37
  • For metrics-server to work you need kubernetes 1.8+ version, could you check the kuberenetes version you're on. Also check if metrics-server pod is up and running in kube-system namespace? – Prafull Ladha Jan 30 '19 at 07:41
  • Kubernetes's Client Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.2"..., Server Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.11"... . What are commands to start metrics-server? Thanks – DaiKeung Jan 30 '19 at 07:56
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/187549/discussion-between-prafull-ladha-and-daikeung). – Prafull Ladha Jan 30 '19 at 08:21

0 Answers0