跳至内容

配置 KEDA Knative Kafka 资源自动伸缩

所有分发事件的 Knative Kafka 组件(源、通道代理)都支持使用 KEDA 对调度数据平面进行伸缩。

重要

此功能处于 Alpha 阶段

启用 Kafka 组件自动伸缩

重要

请注意,启用自动伸缩将为所有 KafkaSources、引用 Kafka Brokers 的触发器以及引用 KafkaChannels 的订阅启用伸缩。

要启用此功能,您需要修改 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、触发器或订阅进行伸缩,可以在资源上设置注释

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

我们使用分析和 Cookie 来了解网站流量。有关您使用我们网站的信息将与 Google 共享,用于该目的。了解更多信息。