我们已在Kubernetes中将自定义的Confluent Kafka连接器部署为statefulset,用于安装Azure KeyVault的机密。这些机密包含db用户名和密码,供在使用Postman通过其余端点https://kafka.mydomain.com/connectors
创建连接器时使用。
这些秘密将作为环境变量加载到容器中。并且kubernetes-ingress-controller
-基于基于路径的路由用于公开其余端点。
到目前为止,我们的团队无法通过Postman创建连接器时使用环境变量。
连接器配置:
{
"name": "TEST.CONNECTOR.SINK",
"config": {
"connector.class": "io.confluent.connect.jdbc.JdbcSinkConnector",
"errors.log.include.messages": "true",
"table.name.format": "AuditTransaction",
"connection.password": "iampassword", <------------ (1)
"flush.size": "3",
"tasks.max": "1",
"topics": "TEST.CONNECTOR.SOURCE-AuditTransaction",
"key.converter.schemas.enable": "false",
"connection.user": "iamuser", <------------ (2)
"value.converter.schemas.enable": "true",
"name": "TEST.CONNECTOR.SINK",
"errors.tolerance": "all",
"connection.url": "jdbc:sqlserver://testdb.database.windows.net:1433;databaseName=mytestdb01",
"value.converter": "org.apache.kafka.connect.json.JsonConverter",
"insert.mode": "insert",
"errors.log.enable": "true",
"key.converter": "org.apache.kafka.connect.json.JsonConverter"
}
}
(1)和(2) -在这里我们要使用具有值-$my_db_username=iamuser
,$my_db_password=iampassword
的系统环境变量。我们尝试在此处使用"$my_db_username"
和"$my_db_password"
,但在Connector Pod的日志中,它无法解析为相应的值。
日志:
[2020-07-28 12:31:22,838] INFO Starting JDBC Sink task (io.confluent.connect.jdbc.sink.JdbcSinkTask:44)
[2020-07-28 12:31:22,839] INFO JdbcSinkConfig values:
auto.create = false
auto.evolve = false
batch.size = 3000
connection.password = [hidden]
connection.url = jdbc:sqlserver://testdb.database.windows.net:1433;databaseName=mytestdb01
connection.user = $my_db_username
db.timezone = UTC
delete.enabled = false
dialect.name =
fields.whitelist = []
insert.mode = insert
max.retries = 10
pk.fields = []
pk.mode = none
quote.sql.identifiers = ALWAYS
retry.backoff.ms = 3000
table.name.format = AuditTransaction
在使用Postman或其他工具创建连接器时,是否可以在此配置中使用系统/容器环境变量?