Skip to content

Conversation

argon-kr
Copy link

@argon-kr argon-kr commented Aug 31, 2025

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
  • New or Enhanced Feature
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, or replicas variables are set to 0,
the replicas field is completely omitted from the generated Deployment manifest.

Before:

spec:
  replicas: 0  # Explicitly defined, can interfere with autoscalers

After:
spec:
  # replicas field omitted when set to 0, Kubernetes defaults to 1

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant