Skip to content

ScalingPolicy API reference

A ScalingPolicy changes configured scaling fields during action windows. It is not a Cron replica trigger. Keep targets within the supported namespace and account for priority when actions overlap; pausing the policy does not directly pause its target workloads.

Group: keda.kedify.io. Kind: ScalingPolicy. Scope: Namespaced.

Defaults below are schema defaults only. “Not specified” does not imply a controller default of zero or false. Required fields are required within their containing object. Runtime behavior can impose additional conditions described in the capability guide.

Served: true; storage: true.

FieldTypeRequiredSchema defaultMeaning and validation
specobjectNoNot specifiedScalingPolicySpec defines the desired state of ScalingPolicy
spec.actionsarrayYesNot specifiedAction is the list of actions to be taken
spec.actions[]objectNoNot specifiedScalingAction defines the action to be taken
spec.actions[].adjustmentobjectYesNot specifiedActionAdjustment defines the adjustment for the action
spec.actions[].adjustment.idleReplicaCountintegerNoNot specifiedIdle replica count applied to ScaledObjects during the window; unsupported for ScaledJobs.
spec.actions[].adjustment.maxReplicaCountintegerNoNot specifiedMaximum replica count applied during the active window.
spec.actions[].adjustment.minReplicaCountintegerNoNot specifiedMinimum replica count applied during the active window.
spec.actions[].adjustment.pauseConfigobjectNoNot specifiedPauseConfig defines the pause configuration
spec.actions[].adjustment.pauseConfig.pausedbooleanNoNot specifiedPaused is the flag to pause the scaling policy autoscaling.keda.sh/paused
spec.actions[].adjustment.pauseConfig.replicasintegerNoNot specifiedReplicas is the number of replicas to be set when the scaling policy is paused autoscaling.keda.sh/paused-replicas
spec.actions[].adjustment.pollingIntervalintegerNoNot specifiedPolling interval in seconds; must not be negative.
spec.actions[].namestringYesNot specifiedNonempty action name; also breaks ties between equal priorities lexicographically.
spec.actions[].priorityintegerNoNot specifiedPriority orders actions when more than one is active at the same time. Higher numeric value means higher priority. Adjustments are merged field by field in ascending priority order (ties broken by lexicographic name), so a non-nil field on the highest-priority action overrides the same field from lower-priority actions; fields left unset fall through to lower-priority values. Required when more than one action is defined.
spec.actions[].triggerobjectNoNot specifiedActionTrigger defines the trigger for the action
spec.actions[].trigger.scheduleobjectYesNot specifiedActionTriggerSchedule defines the schedule for the trigger
spec.actions[].trigger.schedule.endstringYesNot specifiedWindow end as a five-field cron expression, interpreted in the specified timezone.
spec.actions[].trigger.schedule.startstringYesNot specifiedWindow start as a five-field cron expression (minute, hour, day of month, month, day of week).
spec.actions[].trigger.schedule.timezonestringYesNot specifiedRequired IANA timezone, for example Europe/Prague; use UTC to avoid daylight-saving shifts.
spec.targetsarrayYesNot specifiedTargets is the list target resources to be modified
spec.targets[]objectNoNot specifiedScalingActionTarget defines the target resource to be modified
spec.targets[].apiVersionstringNoNot specifiedAPI group/version of the target, for example keda.sh/v1alpha1.
spec.targets[].kindstringYesNot specifiedTarget kind: ScaledObject or ScaledJob.
spec.targets[].namestringYesNot specifiedTarget resource name in the same namespace as the ScalingPolicy.
FieldTypeRequiredSchema defaultMeaning and validation
statusobjectNoNot specifiedScalingPolicyStatus defines the observed state of ScalingPolicy
status.actionsarrayNoNot specified
status.actions[]objectNoNot specifiedScalingPolicyStatusAction defines the status of the action
status.actions[].activebooleanNoNot specified
status.actions[].appliedbooleanNoNot specified
status.actions[].messagestringNoNot specified
status.actions[].namestringNoNot specified
status.actions[].scheduleEndstringNoNot specified
status.actions[].scheduleStartstringNoNot specified
status.activebooleanNoNot specified
status.conditionsarrayNoNot specified
status.conditions[]objectNoNot specifiedCondition contains details for one aspect of the current state of this API Resource.
status.conditions[].lastTransitionTimestringYesNot specifiedlastTransitionTime is the last time the condition transitioned from one status to another. This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
status.conditions[].messagestringYesNot specifiedmessage is a human readable message indicating details about the transition. This may be an empty string. maxLength: 32768
status.conditions[].observedGenerationintegerNoNot specifiedobservedGeneration represents the .metadata.generation that the condition was set based upon. For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance. minimum: 0
status.conditions[].reasonstringYesNot specifiedreason contains a programmatic identifier indicating the reason for the condition’s last transition. Producers of specific condition types may define expected values and meanings for this field, and whether the values are considered a guaranteed API. The value should be a CamelCase string. This field may not be empty. minLength: 1; maxLength: 1024; pattern: ”^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$”
status.conditions[].statusstringYesNot specifiedstatus of the condition, one of True, False, Unknown. enum: [“True”,“False”,“Unknown”]
status.conditions[].typestringYesNot specifiedtype of condition in CamelCase or in foo.example.com/CamelCase. maxLength: 316; pattern: ”^([a-z0-9]([-a-z0-9][a-z0-9])?(\.[a-z0-9]([-a-z0-9][a-z0-9])?)/)?(([A-Za-z0-9][-A-Za-z0-9_.])?[A-Za-z0-9])$”
status.scheduleobjectNoNot specifiedScheduleStatus defines the status of the schedule
status.schedule.lastEndstringNoNot specifiedMost recently recorded window end.
status.schedule.lastStartstringNoNot specifiedMost recently recorded window start.
status.schedule.nextEndstringNoNot specifiedNext scheduled window end reported by the controller.
status.schedule.nextSchedulestringNoNot specifiedNext scheduled controller evaluation time.
status.schedule.nextStartstringNoNot specifiedNext scheduled window start reported by the controller.
status.targetsobjectNoNot specified
status.targets.*objectNoNot specifiedScalingPolicyStatusTarget defines the status of the target
status.targets.*.messagestringNoNot specifiedHuman-readable details of the target condition.
status.targets.*.namestringNoNot specifiedTarget resource name.
status.targets.*.namespacestringNoNot specifiedTarget namespace.
status.targets.*.originalConfigobjectNoNot specifiedActionAdjustment defines the adjustment for the action
status.targets.*.originalConfig.idleReplicaCountintegerNoNot specified
status.targets.*.originalConfig.maxReplicaCountintegerNoNot specified
status.targets.*.originalConfig.minReplicaCountintegerNoNot specified
status.targets.*.originalConfig.pauseConfigobjectNoNot specifiedPauseConfig defines the pause configuration
status.targets.*.originalConfig.pauseConfig.pausedbooleanNoNot specifiedPaused is the flag to pause the scaling policy autoscaling.keda.sh/paused
status.targets.*.originalConfig.pauseConfig.replicasintegerNoNot specifiedReplicas is the number of replicas to be set when the scaling policy is paused autoscaling.keda.sh/paused-replicas
status.targets.*.originalConfig.pollingIntervalintegerNoNot specified
status.targets.*.reasonstringNoNot specifiedMachine-readable reason for the target condition.
status.targets.*.statusstringYesNot specifiedTarget adjustment condition: True, False or Unknown; read reason and message together.
status.validatedGenerationintegerNoNot specifiedResource generation last validated by the controller.
Terminal window
kubectl get crd scalingpolicies.keda.kedify.io -o yaml
kubectl explain scalingpolicy.spec --recursive

Compare served/storage versions and schema before applying configuration. Inspect the resource’s status and events after changing its owning source; schema acceptance alone does not prove successful reconciliation.

An action is a set of rules that define when and how to scale the target. trigger defines when the action should be executed and adjustment defines how the target should be scaled.

Schedules use five-field cron expressions (Minute Hour DayOfMonth Month DayOfWeek).

  • schedule: A cron-like trigger that defines when the action should be executed with the following fields:
    • start: The start time of the schedule. For example 30 6 * * *, at 06:30 AM.
    • end: The end time of the schedule. For example 0 14 * * *, at 02:00 PM.
    • timezone: The timezone of the schedule. For example Europe/Prague.

The following adjustments are supported:

  • pollingInterval: The interval in seconds at which the target should be polled.
  • idleReplicaCount: The number of replicas to scale down to when the target is idle (not supported by ScaledJobs).
  • minReplicaCount: The minimum number of replicas the target should have.
  • maxReplicaCount: The maximum number of replicas the target should have.
  • pauseConfig: Paused related settings.
    • paused: Scaling will paused for a target (ScaledObject or ScaledJob).
    • replicas: Scaling will paused at the specific number of replicas for a target (only ScaledObject is supported).

Example adjustment:

adjustment:
pollingInterval: 10
idleReplicaCount: 0
minReplicaCount: 5
maxReplicaCount: 99
pauseConfig:
replicas: 0
paused: true

You can define overlapping actions with different priorities and the adjustment parameters will get merged with the highest priority value winning (an action with priority: 3 overrides one with priority: 1).

A target is a reference to a resource that you want to apply the scaling policy to. Scaling policy supports only targets in the same namespace.

Supported targets are:

  • ScaledObject
  • ScaledJob