How to know if autoscaling has taken place in Kubernetes

1/28/2019

Is there any way to know that the number of pods have scaled up or down as a result of Horizontal Pod Autoscaling apart from kubectl get hpa command?

I want to trigger a particular file on every scale up or scale down of pods

-- amankedia
autoscaling
kubernetes
kubernetes-helm

1 Answer

1/28/2019

You can use status field of HPA to know when was last time HPA was executed. Details about this can be found with below command:

kubectl explain hpa.status

from this status , you can use lastScaleTime filed for your problem.

lastScaleTime        <string>
 last time the HorizontalPodAutoscaler scaled the number of pods; used by
 the autoscaler to control how often the number of pods is changed.
-- Rajesh Deshpande
Source: StackOverflow