Skip to content

Conversation

@juhosyrjanen
Copy link
Contributor

Description:

This change wraps the Deployment’s spec.replicas field in: {{- if not .Values.hpa.enabled }}, so that the replicas value is only rendered when Horizontal Pod Autoscaling is disabled.

When an HPA is managing the replica count, this prevents GitOps tools from continually attempting to reconcile the Deployment back to a fixed replica value, eliminating unnecessary drift.

Validation:

With generated temporary Helm values:

helm template test charts/gateway-helm \
   -f /tmp/gateway-values.yaml \
   --set hpa.enabled=false \
   --show-only templates/envoy-gateway-deployment.yaml | grep replicas
 replicas: 1

When HPA is enabled:

helm template test charts/gateway-helm \
    -f /tmp/gateway-values.yaml \
    --set hpa.enabled=true \
    --show-only templates/envoy-gateway-deployment.yaml | grep replicas

Fixes #7560

@juhosyrjanen juhosyrjanen requested a review from a team as a code owner November 19, 2025 18:48
@juhosyrjanen juhosyrjanen force-pushed the fix-let-hpa-manage-replicas branch from 6df1084 to d3b6ef9 Compare November 19, 2025 18:51
@arkodg
Copy link
Contributor

arkodg commented Nov 19, 2025

thanks, can you add a test in https://github.com/envoyproxy/gateway/tree/main/test/helm as well as run make testdata && make generate

@codecov
Copy link

codecov bot commented Nov 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.31%. Comparing base (bd27a16) to head (d3a6bc2).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7565      +/-   ##
==========================================
+ Coverage   72.28%   72.31%   +0.03%     
==========================================
  Files         232      232              
  Lines       34114    34114              
==========================================
+ Hits        24658    24670      +12     
+ Misses       7679     7672       -7     
+ Partials     1777     1772       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Wrap the Deployment’s `spec.replicas` in `{{- if not .Values.hpa.enabled
}}` so the field is only rendered when autoscaling is disabled. This
prevents GitOps drift when an HPA is driving scale decisions.

Signed-off-by: Juho Syrjänen <juho.syrjanen@metacoregames.com>
Signed-off-by: Juho Syrjänen <juho.syrjanen@metacoregames.com>
@juhosyrjanen juhosyrjanen force-pushed the fix-let-hpa-manage-replicas branch from c505242 to ece2469 Compare November 19, 2025 20:05
@juhosyrjanen
Copy link
Contributor Author

juhosyrjanen commented Nov 19, 2025

thanks, can you add a test in https://github.com/envoyproxy/gateway/tree/main/test/helm as well as run make testdata && make generate

@arkodg Added a new test for when HPA is disabled and removed the replica specification from the original HPA test. 👍

@arkodg
Copy link
Contributor

arkodg commented Nov 19, 2025

@envoyproxy/gateway-maintainers @envoyproxy/gateway-reviewers should we disable replica when hpa is enabled or ask the user to comment out replica #6249 (comment)

Signed-off-by: Juho Syrjänen <juho.syrjanen@metacoregames.com>
@juhosyrjanen
Copy link
Contributor Author

Seems like me local linter prefers " over '... I reran the generation, my bad!

@cnvergence
Copy link
Member

hi @juhosyrjanen :)
I think this is a correct approach as per https://argo-cd.readthedocs.io/en/stable/user-guide/best_practices/#leaving-room-for-imperativeness
Seems like you need to run helm-generate again

@juhosyrjanen
Copy link
Contributor Author

hi @juhosyrjanen :) I think this is a correct approach as per https://argo-cd.readthedocs.io/en/stable/user-guide/best_practices/#leaving-room-for-imperativeness Seems like you need to run helm-generate again

Oh hi there! :) I will update this as per your comment in a bit!

juhosyrjanen and others added 2 commits November 20, 2025 21:06
@kkk777-7
Copy link
Member

It seems that other OSS projects also omit the replicas field when HPA is enabled, so this approach looks appropriate.

istio : https://github.com/istio/istio/blob/master/manifests/charts/gateway/templates/deployment.yaml#L13
coredns : https://github.com/coredns/helm/pull/116/files

@zirain
Copy link
Member

zirain commented Nov 21, 2025

/retest

@arkodg arkodg merged commit 84cd21c into envoyproxy:main Nov 21, 2025
52 of 55 checks passed
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.

Use Conditional replicas Field in Deployment When HPA Enabled

5 participants