Is there a way in Kubernetes to check when hpa happened?

6/12/2019

I have hpa configured for one of my deployment in Kubernetes.

Is there any way to check if HPA scaling happened to the deployment and when it happened?

I don't have prometheus or any monitoring solutions deployed.

-- karthikeayan
autoscaling
horizontal-scaling
kubernetes
kubernetes-pod

1 Answer

6/12/2019

If you created HPA you can check current status using command

$ kubeclt get hpa

You can also use "watch" flag to refresh view each 30 seconds

$ kubectl get hpa -w

To check if HPA worked you have to describe it

$ kubectl describe hpa <yourHpaName>

Information will be in Events: section.

Also your deployment will contain some information about scaling

$ kubectl describe deploy <yourDeploymentName>
...
Events:
  Type    Reason             Age    From                   Message
  ----    ------             ----   ----                   -------
  Normal  ScalingReplicaSet  11m    deployment-controller  Scaled up replica set php-apache-b5f58cc5f to 1
  Normal  ScalingReplicaSet  9m45s  deployment-controller  Scaled up replica set php-apache-b5f58cc5f to 4
  Normal  ScalingReplicaSet  9m30s  deployment-controller  Scaled up replica set php-apache-b5f58cc5f to 8
  Normal  ScalingReplicaSet  9m15s  deployment-controller  Scaled up replica set php-apache-b5f58cc5f to 10

Another way is use events

$ kubectl get events | grep HorizontalPodAutoscaler
5m20s       Normal    SuccessfulRescale              HorizontalPodAutoscaler   New size: 4; reason: cpu resource utilization (percentage of request) above target
5m5s        Normal    SuccessfulRescale              HorizontalPodAutoscaler   New size: 8; reason: cpu resource utilization (percentage of request) above target
4m50s       Normal    SuccessfulRescale              HorizontalPodAutoscaler   New size: 10; reason:
-- PjoterS
Source: StackOverflow