跳到内容

配置 Knative Kafka 资源的 KEDA 自动扩缩容

所有分发事件的 Knative Kafka 组件(source、channel broker)都支持使用 KEDA 对分发器数据平面进行扩缩容。

重要

此功能为 Alpha 版本

启用 Kafka 组件的自动扩缩容

重要

请注意,启用自动扩缩容将为所有引用 Kafka Broker 的 KafkaSources、Triggers 以及引用 KafkaChannels 的 Subscriptions 启用扩缩容。

要启用此功能,您需要修改 config-kafka-features configmap,并将 controller-autoscaler-keda 标志设置为 enabled。请注意,要使此功能正常工作,您还必须将 KEDA 安装到您的集群中。

更改后,您的 configmap 应该如下所示:

apiVersion: v1
kind: ConfigMap
metadata:
  name: config-kafka-features
  namespace: knative-eventing
data:
  controller-autoscaler-keda: enabled
  # other features and config options...

为资源配置自动扩缩容

如果您想自定义 KEDA 如何扩缩容 KafkaSource、trigger 或 subscription,您可以为该资源设置注解。

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、trigger 或 subscription 的自动扩缩容,您需要为该资源设置注解。

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...

我们使用分析和 cookie 来了解网站流量。有关您使用我们网站的信息会与 Google 共享以达到此目的。了解更多。