Skip to content

feat: add KEDA/HPA managed scaling support#197

Open
m1rl0k wants to merge 1 commit intotemporalio:mainfrom
m1rl0k:feature/keda-hpa-support
Open

feat: add KEDA/HPA managed scaling support#197
m1rl0k wants to merge 1 commit intotemporalio:mainfrom
m1rl0k:feature/keda-hpa-support

Conversation

@m1rl0k
Copy link

@m1rl0k m1rl0k commented Feb 10, 2026

Added opt-in KEDA/HPA scaling support via temporal.io/keda-managed annotation on TemporalWorkerDeployment resources.
When this annotation is present:

  • Non-zero scale operations are filtered out (only scale-to-zero is preserved for sunset behavior)
  • Existing replicas are preserved during deployment updates to avoid fighting KEDA
    This is a ~17 line change in internal/controller/genplan.go that is fully backwards compatible - existing users without the annotation see zero behavior change.

Why?
Users running Temporal workers on Kubernetes often want to use KEDA for autoscaling based on Temporal task queue depth metrics. Currently, the operator's replica management conflicts with KEDA's scaling decisions, causing a "fight" between the two controllers.

This change allows the operator to defer scaling responsibility to KEDA while still handling:

  • Version management and rollouts
  • Scale-to-zero for deprecated/sunset versions
  • All other non-scaling lifecycle operations

Checklist

  1. Closes #N/A (new feature request)

  2. How was this tested:

    • Code review of change paths
    • Verified annotation check is opt-in (no impact to existing users)
    • Logic review: only affects ScaleDeployments and UpdateDeployments replica handling when annotation present
  3. Any docs updates needed?

    • README update recommended to document temporal.io/keda-managed annotation
    • Example KEDA ScaledObject configuration for Temporal task queues would be helpful

When TemporalWorkerDeployment has annotation 'temporal.io/keda-managed',
the controller defers replica scaling to external HPA/KEDA:
- Filters out non-zero scale operations (keeps scale-to-zero for sunset)
- Preserves existing replicas during deployment updates

This allows KEDA to manage worker scaling without fighting the operator.
@m1rl0k m1rl0k requested review from a team and jlegrone as code owners February 10, 2026 23:20
@CLAassistant
Copy link

CLAassistant commented Feb 10, 2026

CLA assistant check
All committers have signed the CLA.

@m1rl0k
Copy link
Author

m1rl0k commented Feb 13, 2026

@jlegrone any objections?

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.

2 participants