-
Notifications
You must be signed in to change notification settings - Fork 781
Description
Describe the feature
Flagger validates spec.autoscalerRef.primaryScalerReplicas.minReplicas to be >= 1, but when using KEDA as an autoscaler, minReplicaCount: 0 is a valid and expected configuration.
This makes it impossible to use Flagger with KEDA scale-to-zero setups.
Error message
Error: 1 error occurred:
* Canary.flagger.app is invalid:
spec.autoscalerRef.primaryScalerReplicas.minReplicas:
Invalid value: 0:
spec.autoscalerRef.primaryScalerReplicas.minReplicas in body should be greater than or equal to 1
Expected behavior
When autoscalerRef points to a KEDA ScaledObject, Flagger should allow minReplicas: 0
This matches KEDA behavior and is required for event-driven / scale-to-zero workloads.
Actual behavior
Flagger enforces minReplicas >= 1, causing Canary creation to fail when minReplicas is set to 0.
Reproduction steps
Use KEDA with a ScaledObject that allows minReplicaCount: 0
Reference it in a Flagger Canary via autoscalerRef
Set primaryScalerReplicas.minReplicas: 0
Apply the Canary
Validation fails with the error above
Canary configuration (relevant part)
autoscalerRef:
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
name: my-app
primaryScalerReplicas:
minReplicas: 0
maxReplicas: 10
Helm template example
This is a common pattern when supporting both critical workloads and KEDA scale-to-zero:
autoscalerRef:
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
name: {{ .Values.name }}
primaryScalerReplicas:
{{- if and .Values.critical.enabled (lt .Values.autoscaling.minReplicas 2.0) }}
minReplicas: 2
{{- else }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
{{- end }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
When .Values.autoscaling.minReplicas = 0, this fails validation even though KEDA supports it.