Kubernetes in Azure cannot display CPU usage for HPA then cannot perform auto-scaling

1/30/2019

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
autoscaling
azure-kubernetes
cpu-usage
kubernetes
missing-data

0 Answers