gcloudDuring node scaling, HPA couldn't get CPU metric.
At the same time, kubectl top pod and kubectl top node output is: Error from server (ServiceUnavailable): the server is currently unable to handle the request (get pods.metrics.k8s.io) Error from server (ServiceUnavailable): the server is currently unable to handle the request (get nodes.metrics.k8s.io)
For more details, I'll show you the flow of my problem occurs:
Insufficient CPU warning occurs when creating pods, thus GKE try node scalie up incrementally.kubectl top node or kubectl top pod doesn’t get a response. - At this time one or more OutOfcpu pods are found, and several pods are inContainerCreating (from Pending state).This causes pod scaling to stop and raises some failures on responding to client’s requests. Is this normal?
I think HPA should get CPU metric(or other metrics) on running pods even during node scaling, to keep track of the optimal pod size at the moment. So when node scaling done, HPA create the necessary pods at once (rather than incrementally).
Can I make my cluster work like this?
Maybe your node runs out of one resource either memory or cpu, there are config maps that describe how addons are scaled depending on the cluster size. You need to edit metrics-server-config config map in kube-system namespace:
kubectl edit cm/metrics-server-config -n kube-systemyou should add
baseCPU
cpuPerNode
baseMemory
memoryPerNodeto NannyConfiguration, here you can find extensive manual:
Also heapster suffers from the same OOM issue: too many pods to handle all metrics within assigned resources please modify heapster's config map in accordingly:
kubectl edit cm/heapster-config -n kube-system