apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
annotations:
autoscaling.keda.sh/paused-replicas: "4"
# ...
You can pause and restart the autoscaling of a workload, as needed.
For example, you might want to pause autoscaling before performing cluster maintenance or to avoid resource starvation by removing non-mission-critical workloads.
You can pause the autoscaling of a scaled object by adding the autoscaling.keda.sh/paused-replicas annotation to the custom metrics autoscaler for that scaled object. The custom metrics autoscaler scales the replicas for that workload to the specified value and pauses autoscaling until the annotation is removed.
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
annotations:
autoscaling.keda.sh/paused-replicas: "4"
# ...
Use the following command to edit the ScaledObject CR for your workload:
$ oc edit ScaledObject scaledobject
Add the autoscaling.keda.sh/paused-replicas annotation with any value:
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
annotations:
autoscaling.keda.sh/paused-replicas: "4" (1)
creationTimestamp: "2023-02-08T14:41:01Z"
generation: 1
name: scaledobject
namespace: my-project
resourceVersion: '65729'
uid: f5aec682-acdf-4232-a783-58b5b82f5dd0
| 1 | Specifies that the Custom Metrics Autoscaler Operator is to scale the replicas to the specified value and stop autoscaling. |
You can restart a paused custom metrics autoscaler by removing the autoscaling.keda.sh/paused-replicas annotation for that ScaledObject.
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
annotations:
autoscaling.keda.sh/paused-replicas: "4"
# ...
Use the following command to edit the ScaledObject CR for your workload:
$ oc edit ScaledObject scaledobject
Remove the autoscaling.keda.sh/paused-replicas annotation.
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
annotations:
autoscaling.keda.sh/paused-replicas: "4" (1)
creationTimestamp: "2023-02-08T14:41:01Z"
generation: 1
name: scaledobject
namespace: my-project
resourceVersion: '65729'
uid: f5aec682-acdf-4232-a783-58b5b82f5dd0
| 1 | Remove this annotation to restart a paused custom metrics autoscaler. |