I am trying to test the Kubernetes HPA like in example here
kubectl run php-apache --image=gcr.io/google_containers/hpa-example --requests=cpu=200m --expose --port=80
kubectl autoscale deployment php-apache --cpu-percent=20 --min=1 --max=10
kubectl get hpa
output is
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
php-apache Deployment/php-apache <unknown> / 20% 1 3 0 1h
Why isn't controller-manager able to get current usage?
Environment details :
failed to compute desired number of replicas based on listed metrics for Deployment/xx/php-apache: failed to get cpu utilization: unable to get metrics for resource cpu: failed to get pod resource metrics: the server cannot complete the requested operation at this time, try again later (get services http:heapster:)
Edit 1 [14-Sep] :
I checked the Heapster API directly for metrics, and I get response.
curl http://10.107.55.59/api/v1/model/namespaces/cp/pods/php-apache-593471247-c65fh/metrics/cpu/usage
{ "metrics": [ { "timestamp": "2017-09-14T13:46:00Z", "value": 19008838 }, { "timestamp": "2017-09-14T13:47:00Z", "value": 19008838 }, { "timestamp": "2017-09-14T13:48:00Z", "value": 19008838 } ], "latestTimestamp": "2017-09-14T13:48:00Z" }
Validate if heapster is fetching data and giving metric, try to run below on kube-api server, replace namespace-name and pod-name in it. it will show metric, if all well, also paste heapster log here
curl http://localhost:8080/api/v1/model/namespaces/{namespace-name}/pods/{pod-name}/metrics/