Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(k8s): add a horizontal pod autoscaler #768

Merged
merged 2 commits into from
Sep 4, 2024
Merged

Conversation

MatMoore
Copy link
Contributor

@MatMoore MatMoore commented Sep 3, 2024

This adds a horizontal pod autoscaler that scales up when the average CPU utilization is at 95% of the requested CPU.

I've deployed to dev, and it seems to work, but the limitranges might need tweaking. Currently the pods are exceeding the requested CPU even with 5 of them, but I'm not sure why.

View the status using kubectl describe hpa -n data-platform-find-moj-data-dev find-moj-data

We should remove the replicas key from the deployment, otherwise any time we deploy it will overwrite the HPA (source:
https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#migrating-deployments-and-statefulsets-to-horizontal-autoscaling)

Behaviour:

  • every 15 seconds - The HPA controller checks the value of the metric used every 15 seconds per pod.
  • every 3 minutes - The HPA scales up pods if the metric threshold has been continually exceeded for 3 mins.
  • every 5 minutes - The HPA scales down pods if the metric threshold has not been exceeded for 5 mins.

Further info:

this scales up when the average CPU utilization is at 95% of the
requested CPU.

We should remove the replicas key from the deployment, otherwise any time
we deploy it will overwrite the HPA (source:
https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#migrating-deployments-and-statefulsets-to-horizontal-autoscaling)

Behaviour:

- every 15 seconds - The HPA controller checks the value of the metric used every 15 seconds per pod.
- every 3 minutes - The HPA scales up pods if the metric threshold has been continually exceeded for 3 mins.
- every 5 minutes - The HPA scales down pods if the metric threshold has not been exceeded for 5 mins.

Further info:

- https://user-guide.cloud-platform.service.justice.gov.uk/documentation/concepts/deploying.html#horizontal-pod-autoscaling-hpa
- https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale
@MatMoore MatMoore force-pushed the horizontal-pod-autoscaler branch from 8d1beb0 to c1d31ca Compare September 4, 2024 09:01
@MatMoore MatMoore marked this pull request as ready for review September 4, 2024 09:16
@MatMoore MatMoore requested a review from a team as a code owner September 4, 2024 09:16
@MatMoore MatMoore force-pushed the horizontal-pod-autoscaler branch from 65982d4 to 95beaac Compare September 4, 2024 10:15
Copy link
Contributor

@tom-webber tom-webber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@MatMoore MatMoore merged commit 467eb5f into main Sep 4, 2024
11 checks passed
@MatMoore MatMoore deleted the horizontal-pod-autoscaler branch September 4, 2024 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants