Kubernetes 启用或禁用 Keda 和 HPA

Ahm*_*lha 3 kubernetes hpa keda

是否有一个“主开关”来启用/禁用 Keda 和 HPA?我可以通过将副本计数编辑为 0 来启用/禁用扩展规则,但是是否有主要的启用/禁用字段?

  cooldownPeriod: 1800
  maxReplicaCount: 8
  minReplicaCount: 2
  pollingInterval: 300
Run Code Online (Sandbox Code Playgroud)

Jyo*_*ayi 6

You can enable/disable scaling rules either by editing the replica count to 0 or you can use a single field called Pause autoscaling.

Pause autoscaling lets you enable/disable autoscaling by using autoscaling.keda.sh/paused-replicas annotation. It can be useful to instruct KEDA to pause autoscaling of objects, if you want to do cluster maintenance or you want to avoid resource starvation by removing non-mission-critical workloads.

You can enable this by adding the below annotation to your ScaledObject definition:

metadata:
  annotations:
    autoscaling.keda.sh/paused-replicas: "0"
Run Code Online (Sandbox Code Playgroud)

The presence of this annotation will pause autoscaling no matter what number of replicas is provided. The above annotation will scale your current workload to 0 replicas and pause autoscaling. You can set the value of replicas for an object to be paused at any arbitrary number. To enable autoscaling again, simply remove the annotation from the ScaledObject definition.

Refer to the KEDA documentation for more information.