# Pause and resume scaling

The Resume Scaling Controller is a controller that allows you to automatically resume scaling for a target (ScaledObject, ScaledJob, or ScalingPolicy) that has been paused. KEDA users can temporarily pause scaling for a target by setting a special annotation on a [ScaledObject](https://keda.sh/docs/concepts/scaling-deployments/#pausing-autoscaling) or [ScaledJob](https://keda.sh/docs/concepts/scaling-jobs/#pausing-autoscaling). For example, to pause scaling for a ScaledObject, you can set the following annotation:

```yaml
metadata:
  annotations:
    autoscaling.keda.sh/paused: "true"
```

Once paused, users need to manually unpause scaling for the target by removing the annotation. The Resume Scaling Controller automates this process by resuming scaling for a target based on a schedule defined by the user.

For a ScalingPolicy, the same annotation pauses the policy controller for that policy. It does not directly pause the target ScaledObjects or ScaledJobs. When resumed, the policy is enabled again and continues applying its configured actions.

## Resume At

*“Resume At”* specifies a particular date in RFC3339 format when the target should be resumed. For example, to resume scaling for a ScaledObject at 06:30 AM on 2025-01-01, you can set the following annotation:

```yaml
metadata:
  annotations:
    autoscaling.keda.sh/paused: "true"
    keda.kedify.io/pause-resume-at: "2025-01-01T06:30:00Z"
```

The Resume Scaling Controller will automatically remove the `autoscaling.keda.sh/paused` annotation at the specified time, resuming scaling for the target.

This feature is GitOps-friendly and can be used to automate scaling operations during maintenance windows. However, a potential drawback is that the timestamp includes a specific time and date with a timezone, which can be challenging to set correctly across multiple timezones.

## Resume After

*“Resume After”* specifies a duration after which the target should be resumed. For example, to resume scaling for a ScaledObject after 1 hour, you can set the following annotation:

```yaml
metadata:
  annotations:
    autoscaling.keda.sh/paused: "true"
    keda.kedify.io/pause-resume-after: "1h"
```

The value of the annotation is a duration in [Go format](https://pkg.go.dev/time#ParseDuration). The Resume Scaling Controller will automatically remove the `autoscaling.keda.sh/paused` annotation after the specified duration, resuming scaling for the target.

This feature is useful for users who want to pause scaling during a maintenance window and automatically resume scaling after the maintenance window ends. A limitation is that the duration is relative and cannot be directly used in GitOps workflows.

Since the duration is a relative time, the Resume Scaling Controller will calculate a specific date in RFC3339 format based on the current time and the specified duration, replacing the value of the `keda.kedify.io/pause-resume-after` annotation.

## Using Resume At and Resume After Together

You can use both annotations together, and the Resume Scaling Controller will prioritize the earlier of the two to resume scaling.

## Paused Reason

You can set a reason for pausing scaling by using the `keda.kedify.io/paused-reason` annotation. This annotation is optional and can provide context for why scaling was paused.

```yaml
metadata:
  annotations:
    autoscaling.keda.sh/paused: "true"
    keda.kedify.io/pause-resume-after: "1h"
    keda.kedify.io/paused-reason: "Maintenance window - patching to version v2.2.0"
```

This annotation is removed when scaling is resumed.

## Example

```yaml
metadata:
  annotations:
    autoscaling.keda.sh/paused: "true"
    autoscaling.keda.sh/paused-replicas: "3"
    keda.kedify.io/pause-resume-after: "1h"
    keda.kedify.io/paused-reason: "Maintenance window - patching to version v2.2.0"
```

After 1 hour, the Resume Scaling Controller will remove all these annotations and resume scaling for the target.

For ScalingPolicy, use the same resume annotations on the policy object:

```yaml
apiVersion: keda.kedify.io/v1alpha1
kind: ScalingPolicy
metadata:
  name: scalingpolicy-sample
  annotations:
    autoscaling.keda.sh/paused: "true"
    keda.kedify.io/pause-resume-after: "1h"
spec:
  # ...
```

## Verify and undo maintenance

Before pausing, record current replicas and ensure enough capacity remains for the maintenance window. Apply the annotations through the ScaledObject/ScaledJob or ScalingPolicy owner; the [annotation reference](https://docs.kedify.io/reference/annotations/) owns their exact values and precedence.

Inspect the target annotations and events before and after the scheduled time. Confirm the pause/resume annotations are removed and a bounded demand change again affects replicas. If the source reconciler re-adds a pause, correct the source rather than repeatedly deleting the live annotation. To cancel maintenance early, remove the pause and resume annotations through the same owner, then verify scaling resumes. For ScalingPolicy, verify policy actions separately from the target autoscaler’s state.

Use [workload diagnostics](https://docs.kedify.io/troubleshooting/workload-scaling/) if activity does not resume. [ScalingPolicy](https://docs.kedify.io/features/scaling-policy/) owns recurring configuration windows; a relative maintenance delay is not a recurring schedule.

---
Canonical: https://docs.kedify.io/features/resume-scaling/
Source: src/content/docs/features/resume-scaling.md
Documentation index: https://docs.kedify.io/llms.txt
