ZooKeeper Authentication¶
New clusters¶
To enable ZooKeeper authentication on brokers, there are two necessary steps:
- Create a JAAS login file and set the appropriate system property to point to it as described above
- Set the configuration property
zookeeper.set.acl
in each broker to true
The metadata stored in ZooKeeper is such that only brokers will be able to modify the corresponding znodes, but znodes are world readable. The rationale behind this decision is that the data stored in ZooKeeper is not sensitive, but inappropriate manipulation of znodes can cause cluster disruption. We also recommend limiting the access to ZooKeeper via network segmentation (only brokers and some admin tools need access to ZooKeeper if the new consumer and new producer are used).
Migrating clusters¶
If you are running a version of Kafka that does not support security or simply with security disabled, and you want to make the cluster secure, then you need to execute the following steps to enable ZooKeeper authentication with minimal disruption to your operations:
- Perform a rolling restart setting the JAAS login file, which enables brokers to authenticate. At the end of the rolling restart, brokers are able to manipulate znodes with strict ACLs, but they will not create znodes with those ACLs
- Perform a second rolling restart of brokers, this time setting the configuration parameter
zookeeper.set.acl
to true, which enables the use of secure ACLs when creating znodes - Execute the ZkSecurityMigrator tool. To execute the tool, there is this script:
bin/zookeeper-security-migration
withzookeeper.acl
set to secure. This tool traverses the corresponding sub-trees changing the ACLs of the znodes
It is also possible to turn off authentication in a secure cluster. To do it, follow these steps:
- Perform a rolling restart of brokers setting the JAAS login file, which enables brokers to authenticate, but setting
zookeeper.set.acl
to false. At the end of the rolling restart, brokers stop creating znodes with secure ACLs, but are still able to authenticate and manipulate all znodes - Execute the ZkSecurityMigrator tool. To execute the tool, run this script
bin/zookeeper-security-migration
withzookeeper.acl
set to unsecure. This tool traverses the corresponding sub-trees changing the ACLs of the znodes - Perform a second rolling restart of brokers, this time omitting the system property that sets the JAAS login file
Here is an example of how to run the migration tool:
bin/zookeeper-security-migration --zookeeper.acl=secure --zookeeper.connection=localhost:2181
Run this to see the full list of parameters:
bin/zookeeper-security-migration --help
Migrating the ZooKeeper ensemble¶
It is also necessary to enable authentication on the ZooKeeper ensemble. To do it, we need to perform a rolling restart of the ensemble and set a few properties. Please refer to the ZooKeeper documentation for more detail: