Skip to content

1. 连接配置字段

Kafka 连接配置位于:

  • config.connection
字段类型说明
bootstrapServersstringbroker 列表(逗号分隔),例如 kafka-1:9092,kafka-2:9092
clientIdstring | null可选 client.id;为空则用 ng-gateway-app-{app_id}
security.protocolenumplaintext / ssl / sasl_plaintext / sasl_ssl
security.tls.*object | nullTLS 配置(仅 ssl / sasl_ssl 生效)
security.sasl.*object | nullSASL 配置(仅 sasl_plaintext / sasl_ssl 生效)

2. TLS 配置(security.tls

字段类型说明(对应 librdkafka ssl.*
caLocationstring | nullCA bundle 路径(ssl.ca.location
certificateLocationstring | nullclient cert 路径(ssl.certificate.location
keyLocationstring | nullprivate key 路径(ssl.key.location
keyPasswordstring | null私钥密码(ssl.key.password
endpointIdentificationAlgorithmstring | nullhostname 校验算法(ssl.endpoint.identification.algorithm),常见为 https 或空字符串(关闭)

容器部署常见坑

证书路径必须是 容器内路径
你需要把证书通过 volume mount 到容器中,并在这里填写容器内路径。


3. SASL 配置(security.sasl

字段类型说明
mechanismenumplain / scram_sha256 / scram_sha512
usernamestringSASL 用户名
passwordstringSASL 密码

4. 示例

4.1 PLAINTEXT

json
{
  "connection": {
    "bootstrapServers": "127.0.0.1:9092",
    "security": { "protocol": "plaintext" }
  }
}

4.2 SASL_SSL + SCRAM-SHA-512

json
{
  "connection": {
    "bootstrapServers": "kafka-1:9093",
    "security": {
      "protocol": "sasl_ssl",
      "tls": {
        "caLocation": "/certs/ca.pem",
        "endpointIdentificationAlgorithm": "https"
      },
      "sasl": {
        "mechanism": "scram_sha512",
        "username": "user",
        "password": "pass"
      }
    }
  }
}

基于 Apache License 2.0 许可发布.