-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #287 from uds5501/feat/acl-integration-gopay
Feature : ACL integration features
- Loading branch information
Showing
15 changed files
with
514 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,100 @@ | ||
KAFKA_TOPICS = topic another-test-topic | ||
KAFKA_BROKERS = kafka1:9095 kafka2:9096 kafka3:9097 | ||
ADMIN_CONFIG = /etc/kafka/secrets/config-admin.properties | ||
KAFKA_CONTAINER = ziggurat_kafka1_1 | ||
|
||
.PHONY: all | ||
all: test | ||
|
||
topic="topic" | ||
another_test_topic="another-test-topic" | ||
# Main target to setup the entire cluster | ||
setup-cluster: down up wait-for-kafka create-scram-credentials create-topics setup-acls | ||
|
||
setup: | ||
docker-compose down | ||
lein deps | ||
docker-compose up -d | ||
sleep 10 | ||
docker exec ziggurat_kafka /opt/bitnami/kafka/bin/kafka-topics.sh --create --topic $(topic) --partitions 3 --replication-factor 1 --zookeeper ziggurat_zookeeper | ||
docker exec ziggurat_kafka /opt/bitnami/kafka/bin/kafka-topics.sh --create --topic $(another_test_topic) --partitions 3 --replication-factor 1 --zookeeper ziggurat_zookeeper | ||
# Bring down all containers and clean volumes | ||
down: | ||
@echo "Bringing down all containers..." | ||
docker-compose -f docker-compose-cluster.yml down -v | ||
|
||
test: setup | ||
TESTING_TYPE=local lein test | ||
docker-compose down | ||
# Start all containers | ||
up: | ||
@echo "Starting all containers..." | ||
docker-compose -f docker-compose-cluster.yml up -d | ||
|
||
setup-cluster: | ||
rm -rf /tmp/ziggurat_kafka_cluster_data | ||
docker-compose -f docker-compose-cluster.yml -p ziggurat down | ||
lein deps | ||
docker-compose -f docker-compose-cluster.yml -p ziggurat up -d | ||
sleep 30 | ||
# Sleeping for 30s to allow the cluster to come up | ||
docker exec ziggurat_kafka1_1 kafka-topics --create --topic $(topic) --partitions 3 --replication-factor 3 --if-not-exists --zookeeper ziggurat_zookeeper_1 | ||
docker exec ziggurat_kafka1_1 kafka-topics --create --topic $(another_test_topic) --partitions 3 --replication-factor 3 --if-not-exists --zookeeper ziggurat_zookeeper_1 | ||
# Wait for Kafka to be ready | ||
wait-for-kafka: | ||
@echo "Waiting for Kafka to be ready..." | ||
@sleep 30 | ||
|
||
# Restart everything | ||
restart: down up wait-for-kafka | ||
|
||
# Create SCRAM credentials for admin user | ||
create-scram-credentials: | ||
@echo "Creating SCRAM credentials for admin user..." | ||
@docker exec $(KAFKA_CONTAINER) kafka-configs \ | ||
--alter \ | ||
--zookeeper zookeeper:2181 \ | ||
--add-config 'SCRAM-SHA-256=[password=admin]' \ | ||
--entity-type users \ | ||
--entity-name admin | ||
|
||
# Create all required topics | ||
create-topics: | ||
@for topic in $(KAFKA_TOPICS); do \ | ||
echo "Creating topic: $$topic"; \ | ||
docker exec $(KAFKA_CONTAINER) kafka-topics \ | ||
--create \ | ||
--zookeeper zookeeper:2181 \ | ||
--if-not-exists \ | ||
--topic $$topic \ | ||
--partitions 3 \ | ||
--replication-factor 3; \ | ||
done | ||
|
||
# Setup ACLs for admin user on all brokers | ||
setup-acls: | ||
@for broker in $(KAFKA_BROKERS); do \ | ||
case $$broker in \ | ||
kafka1:9095) \ | ||
container="ziggurat_kafka1_1" ;; \ | ||
kafka2:9096) \ | ||
container="ziggurat_kafka2_1" ;; \ | ||
kafka3:9097) \ | ||
container="ziggurat_kafka3_1" ;; \ | ||
esac; \ | ||
for topic in $(KAFKA_TOPICS); do \ | ||
echo "Setting up ACLs for topic: $$topic on broker: $$broker using container: $$container"; \ | ||
docker exec $$container kafka-acls \ | ||
--bootstrap-server $$broker \ | ||
--command-config $(ADMIN_CONFIG) \ | ||
--add \ | ||
--allow-principal User:admin \ | ||
--operation All \ | ||
--topic $$topic; \ | ||
done \ | ||
done | ||
|
||
# Clean up topics (can be used during development) | ||
clean-topics: | ||
@for topic in $(KAFKA_TOPICS); do \ | ||
echo "Deleting topic: $$topic"; \ | ||
docker exec $(KAFKA_CONTAINER) kafka-topics --bootstrap-server kafka1:9095 \ | ||
--delete \ | ||
--topic $$topic; \ | ||
done | ||
|
||
# Show logs | ||
logs: | ||
docker-compose -f docker-compose-cluster.yml logs -f | ||
|
||
test-cluster: setup-cluster | ||
TESTING_TYPE=cluster lein test | ||
docker-compose -f docker-compose-cluster.yml down | ||
rm -rf /tmp/ziggurat_kafka_cluster_data | ||
|
||
coverage: setup | ||
coverage: setup-cluster | ||
lein code-coverage | ||
docker-compose down | ||
docker-compose -f docker-compose-cluster.yml down | ||
|
||
|
||
proto: | ||
protoc -I=resources --java_out=test/ resources/proto/example.proto | ||
protoc -I=resources --java_out=test/ resources/proto/person.proto | ||
protoc -I=resources --java_out=test/ resources/proto/person.proto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
security.protocol=SASL_PLAINTEXT | ||
sasl.mechanism=SCRAM-SHA-256 | ||
sasl.jaas.config=org.apache.kafka.common.security.scram.ScramLoginModule required \ | ||
username="admin" \ | ||
password="admin"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
KafkaServer { | ||
org.apache.kafka.common.security.scram.ScramLoginModule required | ||
username="admin" | ||
password="admin"; | ||
}; | ||
|
||
Client { | ||
org.apache.zookeeper.server.auth.DigestLoginModule required | ||
username="admin" | ||
password="admin"; | ||
}; | ||
|
||
KafkaClient { | ||
org.apache.kafka.common.security.scram.ScramLoginModule required | ||
username="client" | ||
password="client-secret"; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.