You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为CFK Kafka Connect资源配置Pod Disruption Budget(PDB)

配置Confluent For Kubernetes Connect集群的PodDisruptionBudget(PDB)

要确保你的8副本Connect集群始终至少有7个实例运行,可以通过两种方式配置PDB:利用CFK(Confluent For Kubernetes)的原生配置支持,或者手动创建独立的PDB资源。

方式一:通过CFK Connect自定义资源直接配置

CFK允许在Connect资源的spec字段中直接定义PDB规则,无需单独创建PDB资源。修改你的Connect配置如下:

---
apiVersion: platform.confluent.io/v1beta1
kind: Connect
metadata:
  name: connect
  namespace: confluent
spec:
  replicas: 8  # 调整为实际的8副本配置
  pdb:
    minAvailable: 7  # 确保至少7个副本始终运行
    # 可选:如果想用百分比,可设置为"87%",但固定数值更适合8副本的场景
  image:
    application: confluentinc/cp-server-connect:7.4.0
    init: confluentinc/confluent-init-container:2.6.0
  tls:
    autoGeneratedCerts: true
  mountedSecrets:
    - secretRef: kafka-client-config-secure
  dependencies:
    kafka:
      bootstrapEndpoint: <cloudKafka_url>:9092
      authentication:
        type: plain
        jaasConfig:
          secretRef: cloud-plain
      tls:
        enabled: true
        ignoreTrustStoreConfig: true 
    schemaRegistry:
      url: https://<cloudSR_url>
      authentication:
        type: basic
        basic:
          secretRef: cloud-sr-access
---

应用修改后的配置:

kubectl apply -f <your-connect-config.yaml> -n confluent

方式二:手动创建独立的PDB资源

如果需要单独管理PDB,可创建如下PDB资源,确保其标签选择器匹配Connect集群的Pod:

---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: connect-pdb
  namespace: confluent
spec:
  minAvailable: 7
  selector:
    matchLabels:
      platform.confluent.io/component: connect
      platform.confluent.io/cluster: connect  # 匹配你的Connect集群名称
---

创建PDB:

kubectl apply -f connect-pdb.yaml -n confluent

关键说明

  • minAvailable: 7 明确指定了集群在节点维护/缩容期间必须保持运行的最小副本数,Karpenetr在执行节点缩容时会遵守该规则,不会同时终止超过1个Connect副本。
  • 若使用百分比配置(如"87%"),Kubernetes会自动计算最小可用数,但对于固定8副本的场景,直接设置数值7更精准,避免四舍五入导致的误差。

内容的提问来源于stack exchange,提问作者Gonda

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.16 03:22:39