Skip to content
This repository was archived by the owner on Feb 22, 2022. It is now read-only.

Commit ceb14f1

Browse files
giacomoguiulfok8s-ci-robot
authored andcommitted
[incubator/kafka]: add reassignPartitions to topic configuration (#7623)
* [incubator/kafka]: add reassignPartitions to topic configuration Signed-off-by: Giacomo Guiulfo <[email protected]> * [incubator/kafka]: bump chart to 0.10.0 Signed-off-by: Giacomo Guiulfo <[email protected]>
1 parent 184af8d commit ceb14f1

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

incubator/kafka/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v1
22
description: Apache Kafka is publish-subscribe messaging rethought as a distributed
33
commit log.
44
name: kafka
5-
version: 0.9.6
5+
version: 0.10.0
66
appVersion: 4.1.2
77
keywords:
88
- kafka

incubator/kafka/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ following configurable parameters:
115115
| `prometheus.operator.enabled` | True if using the Prometheus Operator, False if not | `false` |
116116
| `prometheus.operator.serviceMonitor.namespace` | Namespace which Prometheus is running in. Default to kube-prometheus install. | `monitoring` |
117117
| `prometheus.operator.serviceMonitor.selector` | Default to kube-prometheus install (CoreOS recommended), but should be set according to Prometheus install | `{ prometheus: kube-prometheus }` |
118-
| `topics` | List of topics to create & configure. Can specify name, partitions, replicationFactor, config. See values.yaml | `[]` (Empty list) |
118+
| `topics` | List of topics to create & configure. Can specify name, partitions, replicationFactor, reassignPartitions, config. See values.yaml | `[]` (Empty list) |
119119
| `zookeeper.enabled` | If True, installs Zookeeper Chart | `true` |
120120
| `zookeeper.resources` | Zookeeper resource requests and limits | `{}` |
121121
| `zookeeper.env` | Environmental variables provided to Zookeeper Zookeeper | `{ZK_HEAP_SIZE: "1G"}` |

incubator/kafka/templates/configmap-config.yaml

+13-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,19 @@ data:
2626
done
2727
echo "Applying runtime configuration using {{ .Values.image }}:{{ .Values.imageTag }}"
2828
{{- range $n, $topic := .Values.topics }}
29-
{{- if and $topic.partitions $topic.replicationFactor }}
29+
{{- if and $topic.partitions $topic.replicationFactor $topic.reassignPartitions }}
30+
cat << EOF > {{ $topic.name }}-increase-replication-factor.json
31+
{"version":1, "partitions":[
32+
{{- $partitions := (int $topic.partitions) }}
33+
{{- $replicas := (int $topic.replicationFactor) }}
34+
{{- range $i := until $partitions }}
35+
{"topic":"{{ $topic.name }}","partition":{{ $i }},"replicas":[{{- range $j := until $replicas }}{{ $j }}{{- if ne $j (sub $replicas 1) }},{{- end }}{{- end }}]}{{- if ne $i (sub $partitions 1) }},{{- end }}
36+
{{- end }}
37+
]}
38+
EOF
39+
kafka-reassign-partitions --zookeeper {{ $zk }} --reassignment-json-file {{ $topic.name }}-increase-replication-factor.json --execute
40+
kafka-reassign-partitions --zookeeper {{ $zk }} --reassignment-json-file {{ $topic.name }}-increase-replication-factor.json --verify
41+
{{- else if and $topic.partitions $topic.replicationFactor }}
3042
kafka-topics --zookeeper {{ $zk }} --create --if-not-exists --force --topic {{ $topic.name }} --partitions {{ $topic.partitions }} --replication-factor {{ $topic.replicationFactor }}
3143
{{- else if $topic.partitions }}
3244
kafka-topics --zookeeper {{ $zk }} --alter --force --topic {{ $topic.name }} --partitions {{ $topic.partitions }} || true

incubator/kafka/values.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -311,16 +311,24 @@ prometheus:
311311
## Topic creation and configuration.
312312
## The job will be run on a deployment only when the config has been changed.
313313
## - If 'partitions' and 'replicationFactor' are specified we create the topic (with --if-not-exists.)
314+
## - If 'partitions', 'replicationFactor' and 'reassignPartitions' are specified we reassign the partitions to
315+
## increase the replication factor of an existing topic.
314316
## - If 'partitions' is specified we 'alter' the number of partitions. This will
315317
## silently and safely fail if the new setting isn’t strictly larger than the old (i.e. a NOOP.) Do be aware of the
316318
## implications for keyed topics (ref: https://docs.confluent.io/current/kafka/post-deployment.html#admin-operations)
317319
## - If 'defaultConfig' is specified it's deleted from the topic configuration. If it isn't present,
318320
## it will silently and safely fail.
319321
## - If 'config' is specified it's added to the topic configuration.
320322
##
323+
## Note: To increase the 'replicationFactor' of a topic, 'reassignPartitions' must be set to true (see above).
324+
##
321325
topics: []
322326
# - name: myExistingTopicConfig
323327
# config: "cleanup.policy=compact,delete.retention.ms=604800000"
328+
# - name: myExistingTopicReassignPartitions
329+
# partitions: 8
330+
# replicationFactor: 5
331+
# reassignPartitions: true
324332
# - name: myExistingTopicPartitions
325333
# partitions: 8
326334
# - name: myNewTopicWithConfig

0 commit comments

Comments
 (0)