Skip to main content

KAFKA管理类,提供用户创建、删除、列表查询、修改密码,提供主题创建、删除、列表查询,提供权限创建、删除、列表查询等基础管理功能。

Project description

kafka_admin_service

Kafka admin service class, provides basic management functions such as USER creation, USER deletion, USER listing all and USER password changing, TOPIC creation, TOPIC deletion, TOPIC listing all, and ACL creation, ACL deletion and ACL listing all.

Install

pip install kafka-admin-service

KafkaAdminService methods

  • add_acl
  • change_password
  • create_topic
  • create_topic_and_topic_user
  • create_user
  • delete_acl
  • delete_all_topics
  • delete_all_users
  • delete_topic
  • delete_topic_user_acls
  • delete_user
  • get_acls
  • get_consumer_group_member_assignments
  • get_consumer_group_members
  • get_consumer_groups
  • get_kafka_log_dirs
  • get_kafka_version
  • get_topics
  • get_user_scrams
  • get_users
  • update_user
  • validate_user_password

Why always returns (returncode, stdout, stderr)?

Because we use subprocess.Popen to call kafka's management command under kafka/bin folder. So returncode means the command exit status code, and stdout means the command's normal output, and stderr means the command's error output.

Kafka server requirements.

  1. Kafka using scram auth.
  2. Zookeeper using NO auth.
  3. Set workspace to kafka's root folder. e.g. kafka's command is under folder /path/to/kafka/bin/, so the workspace should set to /path/to/kafka/.
  4. Create scram.jaas file, default to put it at workspace/config/scram.jaas, or set it's path in config file.
  5. Create scram.client.properties file, default to put it at workspace/config/scram.client.properties, or set it's path in config file.
  6. Because we need to call kafka's management commands, normally should install us on kafka server for easy.

Example of ./config/scram.jaas

KafkaServer {
   org.apache.kafka.common.security.scram.ScramLoginModule required
   username="admin"
   password="xxxxxxxx";
};

KafkaClient {
   org.apache.kafka.common.security.scram.ScramLoginModule required
   username="admin"
   password="xxxxxxxx";
};

Example of ./config/scram.client.properties

security.protocol=SASL_PLAINTEXT
sasl.mechanism=SCRAM-SHA-256

Example of application's config.yml

zookeeper: localhost:2181
bootstrap_server: localhost:9092
workspace: /apprun/kafka/
command_config_file: "/apprun/config/scram.client.properties"
default_kafka_opts: "-Djava.security.auth.login.config=/apprun/config/scram.jaas"
topic_partitions: 16
topic_replication_factor: 3
apikeys:
    xxxxxxx:
        appid: xxxx
        other-appinfo: xxx
    yyyyyyy:
        appid: yyyy
        other-appinfo: yyy

Start kafka-admin-server

kafka-admin-server --no-daemon -c config.yml start

Releases

v0.1.1

  • First Release.

v0.1.3

  • Fix kafka commands' path check.
  • Add execute time log.

v0.1.7

  • Add get_user_scrams method.
  • Add validate_user_password method.
  • Fix license_files missing problem.
  • Doc update.

v0.1.9

  • Fix template format parameters missing problem.
  • Fix KAFKA_OPTS missing in calling execute() problem.

v0.2.1

  • Add kafka-admin-server based on xmlrpc.

v0.2.14

  • Add get_consumer_group_member_assignments api.
  • Add get_consumer_group_members api.
  • Add get_consumer_groups api.
  • Add get_kafka_version api.
  • Add get_kafka_log_dirs api.
  • Remove private methods.

v0.2.17

  • Add get_user_configs api。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kafka_admin_service-0.2.18.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kafka_admin_service-0.2.18-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file kafka_admin_service-0.2.18.tar.gz.

File metadata

  • Download URL: kafka_admin_service-0.2.18.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for kafka_admin_service-0.2.18.tar.gz
Algorithm Hash digest
SHA256 111c3e08973707a875c18264d186b9098a297fb6ae8f7c8dfce543ab49a09f5e
MD5 e3423c8e682549247786d05ec94bf486
BLAKE2b-256 623f5a8a4d692317c9a4d49a66764f33a9998023579b5a3115135f497284e84a

See more details on using hashes here.

File details

Details for the file kafka_admin_service-0.2.18-py3-none-any.whl.

File metadata

File hashes

Hashes for kafka_admin_service-0.2.18-py3-none-any.whl
Algorithm Hash digest
SHA256 a2dc164411ec24623baa10d5d2c135f0f3d3e9455ebf6858515a155d3e36b019
MD5 ecb027017eebd83b0116be50b01471a8
BLAKE2b-256 c9918898e02c0a22e806d0cd0adbdcb1b7cc392df5a1130dd58fa39fd92d183f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page