aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStaffan Olsson <staffan@repos.se>2018-02-02 18:31:08 +0100
committerStaffan Olsson <staffan@repos.se>2018-02-02 18:31:08 +0100
commit49649e19bb7775165b6f5409211e05840f5c50ef (patch)
tree9edbf38eb3f257023520430b7bd97fc3a1288622
parente6a7aec8bd4db6cb75617e05dd451f77f9a0cd54 (diff)
parent4257128ef49dd19696944a6691ac52d4487bcf43 (diff)
downloadkubernetes-kafka-49649e19bb7775165b6f5409211e05840f5c50ef.tar.gz
kubernetes-kafka-49649e19bb7775165b6f5409211e05840f5c50ef.tar.bz2
kubernetes-kafka-49649e19bb7775165b6f5409211e05840f5c50ef.zip
Merge branch 'increase-replication-factor' into ops-jobs
motivated by https://github.com/Yolean/kubernetes-kafka/pull/140
-rw-r--r--maintenance/README.md10
-rw-r--r--maintenance/replication-factor-increase-job.yml65
2 files changed, 75 insertions, 0 deletions
diff --git a/maintenance/README.md b/maintenance/README.md
index efe1d81..45684fd 100644
--- a/maintenance/README.md
+++ b/maintenance/README.md
@@ -20,3 +20,13 @@ Create the `preferred-replica-election-job.yml` resource, after deleting any pre
_-- Neha Narkhede, Gwen Shapira, and Todd Palino. ”Kafka: The Definitive Guide”_
Use the `reassign-paritions-job.yml`, after editing `TOPICS` and `BROKERS`.
+
+## Increase a topic's replication factor
+
+See https://github.com/Yolean/kubernetes-kafka/pull/140
+
+Use the `replication-factor-increase-job.yml`, after editing `TOPICS` and `BROKERS`.
+
+The affected topics may end up without a preferred replica. See above to fix that,
+or to affect only your selected topics use [Kafka Manager's](https://github.com/Yolean/kubernetes-kafka/pull/83) topic screen,
+Generate Partition Assignments followed by Reassigned Partitions.
diff --git a/maintenance/replication-factor-increase-job.yml b/maintenance/replication-factor-increase-job.yml
new file mode 100644
index 0000000..de35987
--- /dev/null
+++ b/maintenance/replication-factor-increase-job.yml
@@ -0,0 +1,65 @@
+apiVersion: batch/v1
+kind: Job
+metadata:
+ name: replication-factor-increase
+ namespace: kafka
+spec:
+ template:
+ metadata:
+ name: replication-factor-increase
+ spec:
+ containers:
+ - name: kafka
+ image: solsson/kafka:1.0.0@sha256:17fdf1637426f45c93c65826670542e36b9f3394ede1cb61885c6a4befa8f72d
+ env:
+ - name: ZOOKEEPER
+ value: zookeeper.kafka:2181
+ # the following must be edited per job
+ - name: TOPICS
+ value: ""
+ - name: BROKERS
+ value: 0,1,2
+ command:
+ - /bin/bash
+ - -ce
+ - >
+ if [ -z "$TOPICS" ]; then
+ echo "Please set the TOPICS env (comma-separated) and re-create the job"
+ tail -f /dev/null
+ fi
+
+ echo '{"topics":[' > /tmp/reassign-topics.json;
+ echo -n ' {"topic":"' >> /tmp/reassign-topics.json;
+ echo -n $TOPICS | sed 's/,/"},\n {"topic":"/g' >> /tmp/reassign-topics.json;
+ echo '"}' >> /tmp/reassign-topics.json;
+ echo ']}' >> /tmp/reassign-topics.json;
+
+ echo "# reassign-topics.json";
+ cat /tmp/reassign-topics.json;
+
+ ./bin/kafka-reassign-partitions.sh
+ --zookeeper=$ZOOKEEPER
+ --generate
+ --topics-to-move-json-file=/tmp/reassign-topics.json
+ --broker-list=$BROKERS > /tmp/generated.txt;
+
+ tail -n 1 /tmp/generated.txt > /tmp/proposed-reassignment.json;
+
+ sleep 1;
+ echo "# proposed-reassignment.json";
+ cat /tmp/proposed-reassignment.json;
+
+ sed -i 's/"replicas":\[.\]/"replicas":[0,1,2]/g' /tmp/proposed-reassignment.json;
+ sed -i 's/,"log_dirs":\["any"\]//g' /tmp/proposed-reassignment.json;
+ echo "# proposed-reassignment.json modified to affect replication factor";
+ cat /tmp/proposed-reassignment.json;
+
+ echo "# Triggering kafka-reassign-partitions.sh"
+ ./bin/kafka-reassign-partitions.sh
+ --zookeeper=$ZOOKEEPER
+ --execute
+ --reassignment-json-file=/tmp/proposed-reassignment.json;
+
+ echo "# Reassignment exited. Upon success you may want to run preferred-replica-election."
+ restartPolicy: Never
+ backoffLimit: 3