Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 919
karthikeayan Avatar asked Jun 12 '19 09:06

karthikeayan


People also ask

How long does it take for HPA to scale up?

Default HPA relative metrics tolerance is 10% HPA waits for 3 minutes after the last scale-up events to allow metrics to stabilize. This can also be configured through — horizontal-pod-autoscaler-upscale-delay flag. HPA waits for 5 minutes from the last scale-down event to avoid autoscaler thrashing.

How do you test auto scaling in Kubernetes?

To test that the horizontal pod autoscaler is working properly, you need to load test this service and make sure that the replicas increase proportionately with traffic. To do this, you will run a BusyBox pod that makes an HTTP call to your service, sleeps for 0.01 seconds, and repeats.


1 Answers

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:
like image 148
PjoterS Avatar answered Sep 19 '22 13:09

PjoterS