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

1

17

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.

Lota answered 12/6, 2019 at 9:41 Comment(0)
B
28

If you created HPA you can check current status using command

$ kubectl 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:
Bombard answered 12/6, 2019 at 14:8 Comment(2)
ok, events is where we can find the info. however "describe hpa" gives me error, Error from server (NotFound): the server could not find the requested resourceLota
Did you specify your HPA name? i.e kubectl describe hpa nginx-hpa?Bombard

© 2022 - 2024 — McMap. All rights reserved.