第 25 章 使用 Apache Kafka Drain Cleaner 的 Streams 驱除 pod


Kafka 和 ZooKeeper pod 可能会在 OpenShift 升级、维护或 pod 重新调度过程中被驱除。如果您的 Kafka 和 ZooKeeper pod 由 Apache Kafka 的 Streams 部署,您可以使用 Apache Kafka Drain Cleaner 工具的 Streams 来处理 pod 驱除。Apache Kafka Drain Cleaner 的流处理驱除,而不是 OpenShift。

通过为 Apache Kafka Drain Cleaner 部署流,您可以使用 Cluster Operator 来移动 Kafka pod 而不是 OpenShift。Cluster Operator 确保主题的同步副本数位于或高于配置的 min.insync.replicas,Kafka 可以在驱除过程中保持正常运行。Cluster Operator 会等待主题同步,因为 OpenShift worker 节点会持续排空。

准入 Webhook 通知 Apache Kafka Drain Cleaner 对 Kubernetes API 的 pod 驱除请求的流。然后,Apache Kafka Drain Cleaner 的流向 pod 添加滚动更新注解,以排空。这会通知 Cluster Operator 对被驱除的 pod 执行滚动更新。

注意

如果您不将流用于 Apache Kafka Drain Cleaner,您可以添加 pod 注解来手动执行滚动更新

Webhook 配置

Apache Kafka Drain Cleaner 部署文件的流包括 ValidatingWebhookConfiguration 资源文件。资源提供了将 webhook 注册到 Kubernetes API 的配置。

配置定义了在 pod 驱除请求时要遵循的 Kubernetes API 规则。规则指定仅截获与 pod/eviction 子资源 相关的 CREATE 操作。如果满足这些规则,API 会转发通知。

clientConfig 指向 Apache Kafka Drain Cleaner 服务的流,以及公开 Webhook 的 /drainer 端点。Webhook 使用安全 TLS 连接,这需要身份验证。caBundle 属性指定验证 HTTPS 通信的证书链。证书以 Base64 编码。

pod 驱除通知的 Webhook 配置

apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
# ...
webhooks:
  - name: strimzi-drain-cleaner.strimzi.io
    rules:
      - apiGroups:   [""]
        apiVersions: ["v1"]
        operations:  ["CREATE"]
        resources:   ["pods/eviction"]
        scope:       "Namespaced"
    clientConfig:
      service:
        namespace: "strimzi-drain-cleaner"
        name: "strimzi-drain-cleaner"
        path: /drainer
        port: 443
        caBundle: Cg==
    # ...
Copy to Clipboard Toggle word wrap

25.1. 下载 Apache Kafka Drain Cleaner 部署文件的流

要部署和使用 Apache Kafka Drain Cleaner 的流,您需要下载部署文件。

Apache Kafka Drain Cleaner 部署文件的流可从 Apache Kafka 软件下载页面 的流获得

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat