#!/bin/bash # Локальный операторский клиент CN=kafka-admin. Обычные api и worker этих прав не имеют. set -eu CFG=/etc/kafka/secrets/admin.properties BOOT=kafka:9092 ready=0 for _ in $(seq 1 40); do if /opt/kafka/bin/kafka-broker-api-versions.sh --bootstrap-server "$BOOT" --command-config "$CFG" >/dev/null 2>&1; then ready=1 break fi sleep 2 done if [ "$ready" -ne 1 ]; then echo "kafka did not accept the admin certificate" >&2 exit 1 fi topics() { /opt/kafka/bin/kafka-topics.sh --bootstrap-server "$BOOT" --command-config "$CFG" "$@" } acls() { /opt/kafka/bin/kafka-acls.sh --bootstrap-server "$BOOT" --command-config "$CFG" "$@" } topics --create --if-not-exists --topic attachments.process --partitions 2 --replication-factor 1 topics --create --if-not-exists --topic attachments.failed --partitions 1 --replication-factor 1 topics --create --if-not-exists --topic probe.api --partitions 1 --replication-factor 1 acls --add --allow-principal User:api --operation Write --operation Describe --topic attachments.process acls --add --allow-principal User:api --operation Write --operation Describe --topic probe.api acls --add --allow-principal User:api --operation IdempotentWrite --cluster acls --add --allow-principal User:worker --operation Read --operation Describe --topic attachments.process acls --add --allow-principal User:worker --operation Write --operation Describe --topic attachments.failed acls --add --allow-principal User:worker --operation Read --group attachment-worker acls --add --allow-principal User:worker --operation IdempotentWrite --cluster echo "kafka acls ready"