配置 Knative Kafka 资源的 KEDA 自动扩缩¶
所有调度事件的 Knative Kafka 组件(源、通道代理)都支持使用 KEDA 对调度程序数据平面进行扩缩。
重要
此功能为 Alpha 版
启用 Kafka 组件的自动扩缩¶
重要
请注意,启用自动扩缩将为所有 KafkaSource、引用 Kafka Broker 的 Trigger 以及引用 KafkaChannel 的 Subscription 启用扩缩
要启用此功能,您需要修改 config-kafka-features 配置映射,并将 controller-autoscaler-keda 标志设置为 enabled。请注意,为了使此功能正常工作,您还必须将 KEDA 安装到您的集群中。
更改后,您的配置映射应如下所示
apiVersion: v1
kind: ConfigMap
metadata:
name: config-kafka-features
namespace: knative-eventing
data:
controller-autoscaler-keda: enabled
# other features and config options...
为资源配置自动扩缩¶
如果您想自定义 KEDA 如何扩缩 KafkaSource、触发器或订阅,您可以在资源上设置注解
apiVersion: <eventing|messaging|sources>.knative.dev/v1
kind: <KafkaSource|Subscription|Trigger>
metadata:
annotations:
# The minimum number of replicas to scale down to
autoscaling.eventing.knative.dev/min-scale: "0"
# The maximum number of replicas to scale up to
autoscaling.eventing.knative.dev/max-scale: "50"
# The interval in seconds the autoscaler uses to poll metrics in order to inform its scaling decisions
autoscaling.eventing.knative.dev/polling-interval: "10"
# The period in seconds the autoscaler waits until it scales down
autoscaling.eventing.knative.dev/cooldown-period: "30"
# The lag that is used for scaling (1<->N)
autoscaling.eventing.knative.dev/lag-threshold: "100"
# The lag that is used for activation (0<->1)
autoscaling.eventing.knative.dev: "0"
spec:
# Spec fields for the resource...
为资源禁用自动扩缩¶
如果您想禁用 KafkaSource、触发器或订阅的自动扩缩,您需要在资源上设置注解
apiVersion: <eventing|messaging|sources>.knative.dev/v1
kind: <KafkaSource|Subscription|Trigger>
metadata:
annotations:
autoscaling.eventing.knative.dev/class: disabled
spec:
# Spec fields for the resource...