Kafka Connect
This page describes adding a Kafka Connect Cluster to the Lenses Agent.
Lenses integrates with Kafka Connect Clusters to manage connectors.
sslKeystorePassword:
value: "\${ENV_VAR_NAME}"Simple configuration, with JMX metrics
The URLs (workers) should always have a scheme defined (http:// or https://).
connect:
- name: my-connect-cluster-name
version: 1
tags: ["tag1"]
configuration:
workers:
value:
- http://my-kc.worker1:8083
- http://my-kc.worker2:8083
metricsPort:
value: 9585
metricsType:
value: JMX Basic authentication
For Basic Authentication, define username and password properties.
TLS with custom truststore
A custom truststore is needed when the Kafka Connect workers are served over TLS (encryption-in-transit) and their certificates are not signed by a trusted CA.
TLS with client authentication
A custom truststore might be necessary too (see above).
Adding 3rd Party Connector to the Topology
If you have developed your own Connector or are using not using a Lenses connector you can still display the connector instances in the topology. To do this Lenses needs to know the configuration option of the Connector that defines which topic the Connector reads from or writes to. This is set in the connectors.info parameter in the lenses.conf file.
Keep secrets out of connector configuration
Kafka Connect stores each connector's configuration, including any passwords and keys in it, and returns it in plain text through its REST API. Lenses reads connector configuration through that API, so anyone who can view a connector in Lenses can see these values. So can anyone who can call the Kafka Connect REST API directly, or read the Connect cluster's config topic (config.storage.topic).
To keep secrets out of connector configuration, use Kafka Connect config providers. The connector configuration then holds a reference to each secret instead of the secret itself. The workers resolve the references when they pass the configuration to the connector and its tasks. The REST API, and therefore Lenses, returns only the references.
Apache Kafka includes three config providers:
FileConfigProvider
A properties file on each worker
${file:<path>:<key>}
Kafka 2.0
DirectoryConfigProvider
A directory on each worker, one file per secret, such as a Kubernetes Secret mounted as a volume
${directory:<path>:<file>}
Kafka 2.7
EnvVarConfigProvider
The worker's environment variables
${env:<variable>}
Kafka 3.5
For example, to keep a database password out of a connector's configuration with FileConfigProvider:
Enable the provider on the workers
Add the provider to the configuration of every worker in the Connect cluster, then restart the workers:
Store the secret on the workers
On every worker, put the secret in a file at the same path, readable only by the user that runs the worker:
Reference the secret in the connector
In the connector configuration, replace the secret with a reference to it:
A reference can point to any file or variable that a provider can read, and anyone who can create or edit a connector can write one. Limit each provider to the secrets that connectors need: allowed.paths for FileConfigProvider and DirectoryConfigProvider, as in the example, and allowlist.pattern for EnvVarConfigProvider.
To read secrets from an external store such as HashiCorp Vault, AWS Secrets Manager, or Azure Key Vault, use the Lenses Secret Providers. They are config providers too, so connectors reference their secrets the same way.
Limit who can view and edit connectors
Grant the Kafka Connect permissions in Lenses only to the users and service accounts that need them:
A user who can view a connector (
kafka-connect:GetConnectorDetails) can see its configuration.A user who can create or change a connector (
kafka-connect:CreateConnector,kafka-connect:DeployConnector, orkafka-connect:UpdateConnectorConfiguration) can write references to any secret that the workers' config providers can read.
Scope these permissions to the connectors and Kafka Connect clusters each team owns, with resources such as kafka-connect:connector:<environment>/<cluster>/<connector>, rather than granting them on every connector. Wildcard actions such as kafka-connect:Get* include GetConnectorDetails. See the IAM reference for the actions and resource syntax.
Last updated
Was this helpful?

