Repository navigation
fix(apisix-ingress-controller): restore the HPA template - #1031
geographybuff wants to merge 1 commit into
Conversation
moonming
left a comment
There was a problem hiding this comment.
Thanks for the detailed write-up and the k3d/upgrade testing, @geographybuff! The documentation of the leader-election behavior and the initial replica decrease is especially helpful.
Before merging, I think we need to settle the intended HPA semantics for this workload. With only the leader reconciling, CPU/memory utilization averaged across standby pods may not represent the actual capacity bottleneck. Scaling out can therefore reduce the average without adding reconciliation throughput. Let's get agreement on whether HPA is appropriate here, or whether fixed replicas plus a PDB are the better HA recommendation.
If we keep HPA, please add:
- Committed CI coverage for the HPA and Deployment behavior.
- A migration path for the initial replica decrease when autoscaling is first enabled.
- Handling for Kubernetes 1.22, since
autoscaling/v2requires 1.23+. - Defaults for newly added values under
--reuse-values. Simulating old coalesced values currently rendersmaxReplicas: nullandmetrics: null.
Please also rebase and use a version newer than the already-released chart 1.5.0. Your existing runtime evidence is valuable; the remaining work is to make the behavior and upgrades supportable. Thanks again!
The chart has autoscaling values and pdb.yaml reads them, but the v2 chart update removed templates/hpa.yaml, so autoscaling.enabled=true creates no HorizontalPodAutoscaler. That update also dropped the check that stops the Deployment setting replicas under autoscaling, so restore both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
717076c to
d4ab226
Compare
|
Rebased. Chart version 1.5.1. A maintainer can certainly pick a different chart version number at merge time, because the version might move before then. Fixed replicas with PDB would be fine. Current main already features PDB, so using the PDB route would slim down this PR and keep the code base simpler. The biggest reason I went with HPA was because that was the spec that the issue asked for. So I'll wait for a maintainer to say the word before I switch to fixed replicas with PDB. |
Closes #977.
The chart has
autoscalingvalues andpdb.yamlreads them, but #837 removedtemplates/hpa.yamlduring the v2 update, soautoscaling.enabled=truecreates no HPA. The same PR dropped the check that stops the Deployment settingreplicasunder autoscaling. I found no reason recorded for either removal.Changes:
templates/hpa.yaml, modelled on theapisixchart's templatespec.replicasout of the Deployment when autoscaling is on, sohelm upgradedoesn't reset what the HPA has setmaxReplicas,targetCPUUtilizationPercentageandtargetMemoryUtilizationPercentageto the values, and regenerate the README with helm-docs v1.11.0Decisions for review:
Starting workers, and a standby took over about 30 s after the leader pod was deleted. So this gives failover, not throughput, and the values comment says so. If you'd rather not offer an HPA for that reason, the alternative is to remove theautoscalingvalues and the matching branch inpdb.yaml.autoscaling/v2only. I left out theapisixchart'sversionvalue and itsv2beta1branch.autoscaling/v2needs Kubernetes 1.23, and CI's matrix also lists 1.22, where turning this on would fail. The default is off, and CI'sct installstep doesn't install this chart.maxReplicasis 3, not theapisixchart's 100, because of the leader behavior above. The CPU target is 80 and memory is off, matching this chart's template before feat: update ingress-controller to v2 #837. If both targets are 0, Kubernetes falls back to 80% CPU.Behavior to expect:
autoscaling.enabled=truegets an HPA after upgrading, and the chart stops settingreplicasfor them.deployment.resources.requests, the HPA is created but can't compute utilization. It reportsmissing request for cpu in container managerand doesn't scale. The README says requests are needed.Testing on k3d with k3s v1.35.5, 1 server and 1 agent, controller 2.2.0, adc 0.27.1. Scaling was triggered with a 1m CPU request and a 50% target, without real load:
autoscaling.enabled=trueon masterreplicassetreplicashpa.yamldocument, onlywebhook.yamldiffers, and it also differs between two renders of master because of its generated certificatesScalingActive=Truehelm upgrade, Helm 3.16.4 and 4.3spec.replicasstayed at 3deployment.yaml, Helm 4.3spec.replicasdropped to 1replicas=2, turning autoscaling on, Helm 3.16.4spec.replicasdropped to 1 right after the upgrade, then the HPA raised itreplicas=2, Helm 4.3spec.replicasis 2minReplicas=2, not at 1helm lint,ct lintv3.13.0Not tested: real traffic load, a connected APISIX data plane, the admission webhook with several replicas, and Kubernetes versions other than 1.35.
AI disclosure: Claude Code wrote this change and this description, and ran the tests.
🤖 Generated with Claude Code