Determine group of brokers for topic

Hello,

Is it possible to choose group of broker for one topic and replicas ?

Describe:

I have cluster with 8 brokers and I want to have topic with 2 partitions and 2 replicas
all of partitions should use only brokers 0,1,2,3
paritiotns 2
replication factor 3

if I use --replica-assigment switch I have to choose which broker is for partition but I want that kafka should choose broker for partition and choose only in first 4 brokers group

Is it possible ?

The easiest way to achieve this is to create the topic. Then use bin/kafka-reassign-partitions.sh to move the partitions where you’d like them. You’ll need to create a json file that describes the partition layout, and example is at Post Kafka Deployment | Confluent Documentation(note replicas are the broker ID).