aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsolsson <solsson@gmail.com>2018-02-03 14:53:58 +0100
committerGitHub <noreply@github.com>2018-02-03 14:53:58 +0100
commit85ef561428d2721f03cf3c33b8e277d395ef90e2 (patch)
tree5eaa0a448abe064774182a3fbfabf36e790768a7
parent467fbb9010c11fd5c2c8e95a2d5f146c356c85a4 (diff)
parent77cdb3643a268abf98e9b9859218bebb08283b14 (diff)
downloadkubernetes-kafka-85ef561428d2721f03cf3c33b8e277d395ef90e2.tar.gz
kubernetes-kafka-85ef561428d2721f03cf3c33b8e277d395ef90e2.tar.bz2
kubernetes-kafka-85ef561428d2721f03cf3c33b8e277d395ef90e2.zip
Merge pull request #140 from Yolean/fix-offset-topic-replication
Set internal replication factors to match default and min.insync.replicas
-rw-r--r--kafka/10broker-config.yml6
-rw-r--r--kafka/test/kafkacat.yml11
-rw-r--r--kafka/test/replication-config.yml98
-rw-r--r--yahoo-kafka-manager/kafka-manager.yml2
4 files changed, 106 insertions, 11 deletions
diff --git a/kafka/10broker-config.yml b/kafka/10broker-config.yml
index 1fe67c0..debfda1 100644
--- a/kafka/10broker-config.yml
+++ b/kafka/10broker-config.yml
@@ -113,9 +113,9 @@ data:
############################# Internal Topic Settings #############################
# The replication factor for the group metadata internal topics "__consumer_offsets" and "__transaction_state"
# For anything other than development testing, a value greater than 1 is recommended for to ensure availability such as 3.
- offsets.topic.replication.factor=1
- transaction.state.log.replication.factor=1
- transaction.state.log.min.isr=1
+ #offsets.topic.replication.factor=1
+ #transaction.state.log.replication.factor=1
+ #transaction.state.log.min.isr=1
############################# Log Flush Policy #############################
diff --git a/kafka/test/kafkacat.yml b/kafka/test/kafkacat.yml
index 98410bc..d3c2766 100644
--- a/kafka/test/kafkacat.yml
+++ b/kafka/test/kafkacat.yml
@@ -91,6 +91,7 @@ metadata:
name: kafkacat
namespace: test-kafka
spec:
+ # Note that this test sets a consumer group, but asserts assume that the tests gets its own messages
replicas: 1
selector:
matchLabels:
@@ -101,12 +102,6 @@ spec:
labels:
test-target: kafka-client-kafkacat
test-type: readiness
- # for example:
- # readonly - can be used in production
- # isolated - read/write but in a manner that does not affect other services
- # load - unsuitable for production because it uses significant resources
- # chaos - unsuitable for production because it injects failure modes
- #test-use:
spec:
containers:
- name: producer
@@ -133,11 +128,13 @@ spec:
env:
- name: BOOTSTRAP
value: bootstrap.kafka:9092
+ - name: CONSUMER_GROUP_ID
+ value: test-kafkacat-group
command:
- /bin/bash
- -cex
- >
- kafkacat -C -b $BOOTSTRAP -t test-kafkacat -o -1 -f '%T;%k:%p;%o;%s\n' -u -d broker |
+ kafkacat -b $BOOTSTRAP -G $CONSUMER_GROUP_ID test-kafkacat -o -1 -f '%T;%k:%p;%o;%s\n' -u -d broker |
tee /shared/consumed.tmp
;
volumeMounts:
diff --git a/kafka/test/replication-config.yml b/kafka/test/replication-config.yml
new file mode 100644
index 0000000..abaea49
--- /dev/null
+++ b/kafka/test/replication-config.yml
@@ -0,0 +1,98 @@
+# https://github.com/Yolean/kubernetes-kafka/pull/140
+---
+kind: ConfigMap
+metadata:
+ name: replication-config
+ namespace: test-kafka
+apiVersion: v1
+data:
+
+ setup.sh: |-
+ touch /tmp/testlog
+
+ tail -f /tmp/testlog
+
+ test.sh: |-
+ exec >> /tmp/testlog
+ exec 2>&1
+ set -e
+
+ kafkacat -L -b $BOOTSTRAP > /tmp/metadata
+ BROKERS=$(cat /tmp/metadata | grep -E ' [0-9]+ brokers:' | awk '{print $1}')
+ if (( $BROKERS == 1 )); then
+ echo "Only one broker; no need to check for >1 replication config."
+ exit 0
+ fi
+
+ WITH_TWO_OR_MORE=$(cat /tmp/metadata | grep -E ' replicas: [0-9]+,[0-9]+' | wc -l)
+ WITH_ONE=$(cat /tmp/metadata | grep -E ' replicas: [0-9]+, ' | wc -l)
+ if (( $WITH_TWO_OR_MORE == 0 )); then
+ echo "No partitions have >1 replica, so this is probably normal."
+ exit 0
+ fi
+
+ if (( $WITH_ONE > $MAX_SINGLE_REPLICA_PARTITIONS )); then
+ echo "$(date --iso-8601='ns') There are $WITH_ONE partitions with only one replica. Alerts for under-replicated partitions won't catch that."
+ exit 10
+ fi
+
+ echo "$(date --iso-8601='ns') $WITH_ONE partitions have one replica and WITH_TWO_OR_MORE have more"
+ exit 0
+
+ quit-on-nonzero-exit.sh: |-
+ exec >> /tmp/testlog
+ exec 2>&1
+
+ exit 0
+---
+apiVersion: apps/v1beta2
+kind: ReplicaSet
+metadata:
+ name: replication-config
+ namespace: test-kafka
+spec:
+ # Note that this test sets a consumer group, but asserts assume that the tests gets its own messages
+ replicas: 1
+ selector:
+ matchLabels:
+ test-target: kafka-replication-config
+ test-type: readiness
+ template:
+ metadata:
+ labels:
+ test-target: kafka-replication-config
+ test-type: readiness
+ spec:
+ containers:
+ - name: testcase
+ image: solsson/kafkacat@sha256:b32eedf936f3cde44cd164ddc77dfcf7565a8af4e357ff6de1abe4389ca530c9
+ env:
+ - name: BOOTSTRAP
+ value: bootstrap.kafka:9092
+ - name: MAX_SINGLE_REPLICA_PARTITIONS
+ value: "0"
+ command:
+ - /bin/bash
+ - -e
+ - /test/setup.sh
+ readinessProbe:
+ exec:
+ command:
+ - /bin/bash
+ - -e
+ - /test/test.sh
+ initialDelaySeconds: 30
+ periodSeconds: 60
+ livenessProbe:
+ exec:
+ command:
+ - /bin/bash
+ - -e
+ - /test/quit-on-nonzero-exit.sh
+ volumeMounts:
+ - name: config
+ mountPath: /test
+ volumes:
+ - name: config
+ configMap:
+ name: replication-config
diff --git a/yahoo-kafka-manager/kafka-manager.yml b/yahoo-kafka-manager/kafka-manager.yml
index 77319e4..e176981 100644
--- a/yahoo-kafka-manager/kafka-manager.yml
+++ b/yahoo-kafka-manager/kafka-manager.yml
@@ -15,7 +15,7 @@ spec:
spec:
containers:
- name: kafka-manager
- image: solsson/kafka-manager@sha256:e07b5c50b02c761b3471ebb62ede88afc0625e325fe428316e32fec7f227ff9b
+ image: solsson/kafka-manager@sha256:5db7d54cdb642ec5a92f37a869fdcf2aa479b2552e900b2d2b83b38a1806c2de
ports:
- containerPort: 80
env: