Skip to content

Hpa #3492

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Hpa #3492

wants to merge 10 commits into from

Conversation

nowjean
Copy link

@nowjean nowjean commented Jun 11, 2025

Proposed changes

Write a clear and concise description that helps reviewers understand the purpose and impact of your changes. Use the
following format:

Problem: I want NGF to work with a HorizontalPodAutoscaler

Solution: Add HPA for deployement

Testing: Describe any testing that you did.
I've deployed my AKS cluster and checked hpa working correctly.

Closes #3447

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have updated necessary documentation
  • I have rebased my branch onto main
  • I will ensure my PR is targeting the main branch and pulling from my branch from my own fork

Release notes

If this PR introduces a change that affects users and needs to be mentioned in the release notes,
please add a brief note that summarizes the change.


nowjean added 2 commits June 11, 2025 18:18
Copy link

nginx-bot bot commented Jun 11, 2025

Hi @nowjean! Welcome to the project! 🎉

Thanks for opening this pull request!
Be sure to check out our Contributing Guidelines while you wait for someone on the team to review this.

@nginx-bot nginx-bot bot added the community label Jun 11, 2025
Copy link
Contributor

github-actions bot commented Jun 11, 2025

🎉 Thank you for your contribution! It appears you have not yet signed the F5 Contributor License Agreement (CLA), which is required for your changes to be incorporated into an F5 Open Source Software (OSS) project. Please kindly read the F5 CLA and reply on a new comment with the following text to agree:


I have hereby read the F5 CLA and agree to its terms


1 out of 2 committers have signed the CLA.
✅ (nowjean)[https://github.com/nowjean]
@nowjean
Nowjean seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@github-actions github-actions bot added the helm-chart Relates to helm chart label Jun 11, 2025
@nowjean
Copy link
Author

nowjean commented Jun 11, 2025

I have hereby read the F5 CLA and agree to its terms

@sjberman sjberman moved this from 🆕 New to External Pull Requests in NGINX Gateway Fabric Jun 12, 2025
@salonichf5
Copy link
Contributor

Thank you for you contribution to the project. Please run make generate-all from root directory to auto generate schema files.

Comment on lines 159 to 190
autoscaling:
enabled: false
annotations: {}
minReplicas: 1
maxReplicas: 11
targetCPUUtilizationPercentage: 50
targetMemoryUtilizationPercentage: 50
behavior: {}
# scaleDown:
# stabilizationWindowSeconds: 300
# policies:
# - type: Pods
# value: 1
# periodSeconds: 180
# scaleUp:
# stabilizationWindowSeconds: 300
# policies:
# - type: Pods
# value: 2
# periodSeconds: 60
autoscalingTemplate: []
# Custom or additional autoscaling metrics
# ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-custom-metrics
# - type: Pods
# pods:
# metric:
# name: nginx_gateway_fabric_nginx_process_requests_total
# target:
# type: AverageValue
# averageValue: 10000m

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: add one-line descriptions for these fields, similar to how it's done for the others, to improve readability for users.

Copy link
Author

Choose a reason for hiding this comment

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

I've added comments!

@nowjean nowjean requested a review from a team as a code owner June 14, 2025 01:31
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Jun 14, 2025
@nowjean
Copy link
Author

nowjean commented Jun 14, 2025

Thank you for you contribution to the project. Please run make generate-all from root directory to auto generate schema files.

I’ve completed 'make generate-all'. Could you please review my PR?

@nowjean nowjean force-pushed the hpa branch 2 times, most recently from 172c009 to d081d68 Compare June 14, 2025 07:20
@sjberman
Copy link
Collaborator

sjberman commented Jun 17, 2025

So this only affects the control plane, correct? We probably want to support this for the nginx data plane as well (seems like that would be the more beneficial use case).

In order to configure deployment options for the data plane, it requires a bit more work, specifically in our APIs and the code itself. The NginxProxy CRD holds the deployment configuration for the nginx data plane, which the control plane uses to configure the data plane when deploying it.

Here is a simple example of how we add a new field to the API to allow for configuring these types of deployment fields: #3319.

@sjberman sjberman added the enhancement New feature or request label Jun 17, 2025
@sjberman
Copy link
Collaborator

I'd also love a more descriptive PR title, as well as a release note in the description so we can include this feature in our release notes :)

@nowjean
Copy link
Author

nowjean commented Jun 17, 2025

@sjberman Yes, this PR only affects the control plane. Can we also implement HPA for the data plane?

AFAIK, the data plane Deployment is created by the NginxProxy CRD, and its name depends on the Gateway's name parameter. This means we can't assume a fixed name in values.yaml.

HPA only applies to Deployments with a fixed name, like:

scaleTargetRef:
  apiVersion: apps/v1
  kind: Deployment
  name: my-app

So, I think we can't implement HPA via the Helm chart, especially since data plane and control plane pods are now separated in 2.0.
Do you have any suggestions or recommended approaches for enabling HPA on the data plane?

@sjberman
Copy link
Collaborator

@nowjean I updated my comment with a description on how it can be implemented on the data plane side. Glad we're on the same page :)

@salonichf5
Copy link
Contributor

Thank you for you contribution to the project. Please run make generate-all from root directory to auto generate schema files.

I’ve completed 'make generate-all'. Could you please review my PR?

Will manual test this PR for both control plane and data plane when we have all the changes :)

@github-actions github-actions bot removed the enhancement New feature or request label Jun 20, 2025
@nowjean
Copy link
Author

nowjean commented Jun 20, 2025

@sjberman @salonichf5 I've pushed my changes to this PR.
This is my first time working with Golang and creating CRDs, so I’d appreciate your review.

From my testing, the code correctly applies HPA to both the control plane and data plane.
To enable this, please set nginx.autoscaling.enabled: true and configure nginx.container.resources accordingly.
dataplane
controlplane

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community documentation Improvements or additions to documentation helm-chart Relates to helm chart
Projects
Status: External Pull Requests
Development

Successfully merging this pull request may close these issues.

HorizontalPodAutoscaler Support
3 participants