Fix KServe minReplicas=0 Support for Scale-to-Zero#1427
Open
Leoyzen wants to merge 1 commit intokubeflow:masterfrom
Open
Fix KServe minReplicas=0 Support for Scale-to-Zero#1427Leoyzen wants to merge 1 commit intokubeflow:masterfrom
Leoyzen wants to merge 1 commit intokubeflow:masterfrom
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
…t on update
This commit fixes two issues with minReplicas configuration in KServe:
1. Helm template condition fix:
- Changed template condition from 'if .Values.minReplicas' to
'if ge (int .Values.minReplicas) 0'
- This ensures minReplicas=0 is correctly rendered instead of being
ignored (since 0 is falsy in Helm)
2. Update command default value fix:
- Changed default value of --min-replicas flag from 1 to -1 in
update_serving_kserve.go
- Update logic only applies when args.MinReplicas >= 0
- Now updating other fields won't reset minReplicas to 1
Files changed:
- charts/kserve/templates/inferenceservice.yaml
- charts/kserve/values.yaml
- pkg/argsbuilder/update_serving_kserve.go
Fixes scale-to-zero (minReplicas=0) functionality for KServe inference
services.
13d45a6 to
90b87b6
Compare
Member
|
@Leoyzen Thanks for reporting and fixing the issue! Could you sign off your commits to pass the DCO check? See Contributing | Kubeflow. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
This PR addresses two critical issues with the
minReplicasconfiguration in KServe:Issue 1: Helm Template Condition Fails for minReplicas=0
The Helm template used
{{- if .Values.minReplicas }}to conditionally render theminReplicasfield. In Helm, the value0is falsy, so when users setminReplicas: 0to enable scale-to-zero, the configuration was silently ignored and not rendered in the generated manifest.Issue 2: Update Command Resets minReplicas to 1
When updating an InferenceService with any field (not
--min-replicas), theminReplicasvalue was always reset to1. This occurred because:--min-replicasflag was1in the update commandif args.MinReplicas >= 0, which was always true (default1 >= 0)minReplicassettings, breaking scale-to-zero deploymentsSolution
1. Fixed Helm Template Condition
Changed the condition from:
{{- if .Values.minReplicas }}To:
{{- if ge (int .Values.minReplicas) 0 }}This ensures that
minReplicas=0is correctly rendered since0 >= 0evaluates totrue.2. Fixed Update Command Default Value
Changed the default value of
--min-replicasflag inupdate_serving_kserve.gofrom1to-1:Now:
--min-replicasis not specified,args.MinReplicas = -1, condition>= 0isfalse, no update occurs--min-replicas 0is explicitly set,args.MinReplicas = 0, condition>= 0istrue, updates to0--min-replicas <N>(N>0) is explicitly set, updates to the specified valueFiles Changed
charts/kserve/templates/inferenceservice.yaml- Fixed Helm template conditioncharts/kserve/values.yaml- Added default values forminReplicas: 0andmaxReplicas: 10pkg/argsbuilder/update_serving_kserve.go- Changed default--min-replicasto-1Behavior
Create New InferenceService:
minReplicasremains1(no breaking change)--min-replicas 0for scale-to-zeroUpdate InferenceService:
minReplicas--min-replicas 0to enable scale-to-zero--min-replicas <N>to change the valueTesting Recommendations
--min-replicas 0and verify scale-to-zero worksminReplicasis preserved--min-replicas 0and verify it enables scale-to-zerominReplicascontinue to work as beforeRelated
This fix enables true scale-to-zero functionality for KServe inference services, which is essential for cost optimization in development/test environments and low-traffic production workloads.