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
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.