Update Skip replicas field when set to 0 for autoscaler(eg. KEDA) compatibility #2078
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.
SUMMARY
Skip replicas field definition when set to 0 to improve compatibility with Kubernetes autoscalers.
When replicas is explicitly set to 0, omitting the field from the Deployment spec allows autoscalers to take full control of scaling decisions without conflicts.
This approach has the advantage of explicitly indicating that the workload is managed by external autoscaling solutions, making the scaling ownership clear in the deployment configuration.
ISSUE TYPE
ADDITIONAL INFORMATION
Modified the replicas condition logic in both task.yaml.j2 and web.yaml.j2 templates to add
|int != 0
checks.This ensures that when
task_replicas
,web_replicas
, orreplicas
variables are set to 0,the replicas field is completely omitted from the generated Deployment manifest.
Before:
This change enables seamless integration with various Kubernetes autoscaling solutions (HPA, VPA, KEDA, etc.) that require complete control over replica management.
Test Updates:
Updated molecule test expectations to reflect the new behavior where omitted replicas field defaults to 1 instead of 0.