Command-line utilities¶
Charmed Apache Kafka includes the Apache Kafka command-line utilities on both substrates. The packaging and invocation differ:
On machines, the
charmed-kafkasnap exposes commands namedcharmed-kafka.<command>.On Kubernetes, the utilities are executable scripts in the workload container. Apache Kafka scripts are under
/opt/kafka/bin, Cruise Control is under/opt/cruise-control/bin, andkeytoolis available onPATH.
Run a utility¶
Run a snap command on a Kafka unit:
juju ssh kafka/leader sudo -i \
'charmed-kafka.<command> <arguments>'
For example:
juju ssh kafka/leader sudo -i \
'charmed-kafka.topics \
--bootstrap-server <bootstrap-server> \
--command-config /var/snap/charmed-kafka/current/etc/kafka/client.properties \
--list'
List all snap applications with:
snap info charmed-kafka
Run an Apache Kafka or Cruise Control executable in the kafka workload
container:
juju ssh --container kafka kafka/leader \
'<absolute-path> <arguments>'
For example:
juju ssh --container kafka kafka/leader \
'/opt/kafka/bin/kafka-topics.sh \
--bootstrap-server <bootstrap-server> \
--command-config /etc/kafka/client.properties \
--list'
For Kafka Connect utilities, use the kafka-connect workload container:
juju ssh --container kafka-connect kafka-connect-k8s/leader \
'/opt/kafka/bin/connect-plugin-path.sh --help'
Use absolute paths on Kubernetes. Variables such as $BIN and $CONF, and the
environment assigned to a Pebble service, are not guaranteed to be present in
an interactive command.
Tip
Commands enclosed in single quotes are expanded inside the unit or container.
Use double quotes if a variable defined in your local shell must be expanded
before the command is sent through juju ssh.
Command mapping¶
Purpose |
Machine snap command |
Kubernetes executable |
Kubernetes container |
|---|---|---|---|
Kafka service entry point |
|
|
|
Cruise Control service entry point |
|
|
|
Describe log directories |
|
|
|
Format or inspect storage |
|
|
|
Consumer performance test |
|
|
|
Producer performance test |
|
|
|
Manage configuration |
|
|
|
Manage topics |
|
|
|
Console consumer |
|
|
|
Console producer |
|
|
|
Manage consumer groups |
|
|
|
Get topic offsets |
|
|
|
Reassign partitions |
|
|
|
Verify replicas |
|
|
|
Run a Kafka class |
|
|
|
Reset a Streams application |
|
|
|
Manage transactions |
|
|
|
Trigger leader election |
|
|
|
Inspect log segments |
|
|
|
Manage ACLs |
|
|
|
Inspect the cluster ID |
|
|
|
Run a verifiable consumer |
|
|
|
Run a verifiable producer |
|
|
|
Run |
|
|
|
Inspect the KRaft quorum |
|
|
|
Kafka Connect service entry point |
|
|
|
Inspect the Connect plugin path |
|
|
|
Manage Java keys and certificates |
|
|
|
Warning
Do not manually start kafka-server-start.sh,
kafka-cruise-control-start.sh, or connect-distributed.sh on a
charm-managed deployment. They are service entry points managed by the charm
through snap services on machines or Pebble on Kubernetes.
Client configuration¶
Most administrative commands require a bootstrap server and a client configuration file containing the cluster administrator credentials.
Kafka client configuration:
/var/snap/charmed-kafka/current/etc/kafka/client.propertiesKRaft client configuration:
/var/snap/charmed-kafka/current/etc/kafka/kraft-client.properties
The machine charm also writes $BIN, $CONF, $LOGS, and $DATA to
/etc/environment.
Kafka client configuration:
/etc/kafka/client.propertiesKRaft client configuration:
/etc/kafka/kraft-client.propertiesKafka Connect worker configuration:
/etc/connect/connect-distributed.properties
Use absolute paths when invoking commands in a workload container.
Machine snap wrappers¶
The machine snap applications add environment settings required by the packaged workload:
bin-wrapper.bashis used by most Kafka utilities. It sets the Kafka log directory and default tool logging configuration, and disables JMX for the invocation.The Kafka and Cruise Control start wrappers configure their service environments and drop privileges to the confined
_daemon_user.connect-wrapper.bashsets the Connect logging configuration, disables JMX, and starts Connect with the snap-managed worker configuration.charmed-kafka.keytoolinvokes the bundled JDK utility directly.
Kubernetes commands invoke the scripts directly and do not use these snap wrappers. When a command needs custom Java, JMX, or logging settings, provide the relevant environment variables explicitly.
The charmed.kafka.log.level property used by the snap’s log4j2.yaml is specific to the
charmed-kafka package and is not an upstream Apache Kafka property. For upstream options, see the
Apache Kafka configuration and
JMX monitoring
documentation.