Edit: In order to avoid 80's style solutions (such as shown in this answer), please take a look at Dirk's answer.
I just love bash/sh
For already created topics, you'd have to execute a partition reassignment operation.
If you wish to control the ISR for newly created topics, you could wrap the kafka-topics.sh script in a new script, lets call it createTopics.sh:
#!/bin/bash
isr=0
if [[ $1 = \logs* ]]; then
isr=1
elif [[ $1 = \app* ]]; then
isr=2
elif [[ $1 = \core* ]]; then
isr=4
fi
/bin/kafka-topics.sh --create --topic $1 --replication-factor $isr \
--partitions $3 --bootstrap-server $2
$1 - topic name
$2 - bootstrap-server
$3 - partitions
For example:
./createTopics.sh apps-topic localhost:9092 1 && \
./createTopics.sh core-topic localhost:9092 1
This would create two new topics with their respective replication-factor:
apps-topic > ISR = 2.
core-topic > ISR = 4.
(max ISR value, assuming all replicas are in-sync)
The script would also validate the creation of new topics, as it wouldn't create any topic which name doesn't start with one of these: logs / app / core. Kafka would show an error, Replication factor must be larger than 0.
You could change this behaviour in order to allow different topic prefixes, by setting the default isr value at the start of the script different than 0: isr=1, for example. This would lead to:
#!/bin/bash
isr=1
if [[ $1 = \app* ]]; then
isr=2
elif [[ $1 = \core* ]]; then
isr=4
fi
/bin/kafka-topics.sh --create --topic $1 --replication-factor $isr \
--partitions $3 --bootstrap-server $2