Skip to content

Commit d1377a5

Browse files
committed
Adds a job that can actually fix under-replication ...
as long as you have one up-to-date replica. The use case is broker outages that are longer than mere re-scheduling, such as zone outage in a multi-zone cluster.
1 parent 7428403 commit d1377a5

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
apiVersion: batch/v1
2+
kind: Job
3+
metadata:
4+
name: reassign-partitions
5+
namespace: kafka
6+
spec:
7+
template:
8+
metadata:
9+
name: reassign-partitions
10+
spec:
11+
containers:
12+
- name: kafka
13+
image: solsson/kafka:1.0.0@sha256:17fdf1637426f45c93c65826670542e36b9f3394ede1cb61885c6a4befa8f72d
14+
env:
15+
- name: ZOOKEEPER
16+
value: zookeeper.kafka:2181
17+
# the following must be edited per job
18+
- name: TOPICS
19+
value: test-produce-consume,test-kafkacat
20+
- name: BROKERS
21+
value: 0,2
22+
command:
23+
- /bin/bash
24+
- -ce
25+
- >
26+
echo '{"topics":[' > /tmp/reassign-topics.json;
27+
echo -n ' {"topic":"' >> /tmp/reassign-topics.json;
28+
echo -n $TOPICS | sed 's/,/"},\n {"topic":"/g' >> /tmp/reassign-topics.json;
29+
echo '"}' >> /tmp/reassign-topics.json;
30+
echo ']}' >> /tmp/reassign-topics.json;
31+
32+
echo "# reassign-topics.json";
33+
cat /tmp/reassign-topics.json;
34+
35+
./bin/kafka-reassign-partitions.sh
36+
--zookeeper=$ZOOKEEPER
37+
--generate
38+
--topics-to-move-json-file=/tmp/reassign-topics.json
39+
--broker-list=$BROKERS > /tmp/generated.txt;
40+
41+
tail -n 1 /tmp/generated.txt > /tmp/proposed-reassignment.json;
42+
43+
echo "# proposed-reassignment.json";
44+
cat /tmp/proposed-reassignment.json;
45+
46+
./bin/kafka-reassign-partitions.sh
47+
--zookeeper=$ZOOKEEPER
48+
--execute
49+
--reassignment-json-file=/tmp/proposed-reassignment.json;
50+
restartPolicy: Never
51+
backoffLimit: 3

0 commit comments

Comments
 (0)