Allow customization of how keda scales up and down instead of allowin…

PE
6d ago
+58-0

Allow customization of how KEDA scales workers and webhook processors up and down, instead of jumping straight to the computed replica count.

Description

When KEDA is enabled with minReplicaCount >= 1, replica changes between min and max are handled by the Kubernetes HPA. By default, the HPA can scale directly to the target count in a single step (e.g. 3→20 on scale-up or 20→3 on scale-down), which can cause sudden capacity swings and disrupt in-flight workflow executions.

This change exposes KEDA's advanced ScaledObject configuration on both worker and webhook-processor ScaledObjects via new values:

  • keda.worker.advanced
  • keda.webhookProcessor.advanced

When set, these are rendered into the ScaledObject's spec.advanced block (typically horizontalPodAutoscalerConfig.behavior) so operators can cap how many pods are added or removed per interval. Default remains {}, preserving existing behavior for current deployments.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Example/configuration update
  • CI/CD improvements

Related Issues

Fixes # (issue)
Relates to # (issue)

Testing Performed

Deployment Testing (if applicable)

  • Tested with minimal configuration
  • Tested with production configuration
  • Tested upgrade path from previous version
  • All pods start successfully
  • Application is accessible

Specific Testing for Changes

Describe any specific testing you performed for your changes:

  • helm template test charts/n8n -f charts/n8n/examples/keda-autoscaling.yaml --dry-run=client — renders successfully with advanced: {} (no advanced block in ScaledObject)
  • Verified ScaledObject templates include spec.advanced only when keda.worker.advanced / keda.webhookProcessor.advanced is non-empty
  • Confirmed default {} leaves existing KEDA Redis scaling behavior unchanged

Breaking Changes

If this includes breaking changes, describe what they are and provide migration instructions:

  • None. advanced defaults to {} and is omitted from rendered ScaledObjects unless configured.

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation, README.md, examples
  • My changes generate no new warnings or errors
  • I have added examples that demonstrate the changes (if applicable)
  • All new and existing tests pass