Skip to content

Commit 85ef561

Browse files
authored
Merge pull request #140 from Yolean/fix-offset-topic-replication
Set internal replication factors to match default and min.insync.replicas
2 parents 467fbb9 + 77cdb36 commit 85ef561

File tree

4 files changed

+106
-11
lines changed

4 files changed

+106
-11
lines changed

kafka/10broker-config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ data:
113113
############################# Internal Topic Settings #############################
114114
# The replication factor for the group metadata internal topics "__consumer_offsets" and "__transaction_state"
115115
# For anything other than development testing, a value greater than 1 is recommended for to ensure availability such as 3.
116-
offsets.topic.replication.factor=1
117-
transaction.state.log.replication.factor=1
118-
transaction.state.log.min.isr=1
116+
#offsets.topic.replication.factor=1
117+
#transaction.state.log.replication.factor=1
118+
#transaction.state.log.min.isr=1
119119
120120
############################# Log Flush Policy #############################
121121

kafka/test/kafkacat.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ metadata:
9191
name: kafkacat
9292
namespace: test-kafka
9393
spec:
94+
# Note that this test sets a consumer group, but asserts assume that the tests gets its own messages
9495
replicas: 1
9596
selector:
9697
matchLabels:
@@ -101,12 +102,6 @@ spec:
101102
labels:
102103
test-target: kafka-client-kafkacat
103104
test-type: readiness
104-
# for example:
105-
# readonly - can be used in production
106-
# isolated - read/write but in a manner that does not affect other services
107-
# load - unsuitable for production because it uses significant resources
108-
# chaos - unsuitable for production because it injects failure modes
109-
#test-use:
110105
spec:
111106
containers:
112107
- name: producer
@@ -133,11 +128,13 @@ spec:
133128
env:
134129
- name: BOOTSTRAP
135130
value: bootstrap.kafka:9092
131+
- name: CONSUMER_GROUP_ID
132+
value: test-kafkacat-group
136133
command:
137134
- /bin/bash
138135
- -cex
139136
- >
140-
kafkacat -C -b $BOOTSTRAP -t test-kafkacat -o -1 -f '%T;%k:%p;%o;%s\n' -u -d broker |
137+
kafkacat -b $BOOTSTRAP -G $CONSUMER_GROUP_ID test-kafkacat -o -1 -f '%T;%k:%p;%o;%s\n' -u -d broker |
141138
tee /shared/consumed.tmp
142139
;
143140
volumeMounts:

kafka/test/replication-config.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# https://github.com/Yolean/kubernetes-kafka/pull/140
2+
---
3+
kind: ConfigMap
4+
metadata:
5+
name: replication-config
6+
namespace: test-kafka
7+
apiVersion: v1
8+
data:
9+
10+
setup.sh: |-
11+
touch /tmp/testlog
12+
13+
tail -f /tmp/testlog
14+
15+
test.sh: |-
16+
exec >> /tmp/testlog
17+
exec 2>&1
18+
set -e
19+
20+
kafkacat -L -b $BOOTSTRAP > /tmp/metadata
21+
BROKERS=$(cat /tmp/metadata | grep -E ' [0-9]+ brokers:' | awk '{print $1}')
22+
if (( $BROKERS == 1 )); then
23+
echo "Only one broker; no need to check for >1 replication config."
24+
exit 0
25+
fi
26+
27+
WITH_TWO_OR_MORE=$(cat /tmp/metadata | grep -E ' replicas: [0-9]+,[0-9]+' | wc -l)
28+
WITH_ONE=$(cat /tmp/metadata | grep -E ' replicas: [0-9]+, ' | wc -l)
29+
if (( $WITH_TWO_OR_MORE == 0 )); then
30+
echo "No partitions have >1 replica, so this is probably normal."
31+
exit 0
32+
fi
33+
34+
if (( $WITH_ONE > $MAX_SINGLE_REPLICA_PARTITIONS )); then
35+
echo "$(date --iso-8601='ns') There are $WITH_ONE partitions with only one replica. Alerts for under-replicated partitions won't catch that."
36+
exit 10
37+
fi
38+
39+
echo "$(date --iso-8601='ns') $WITH_ONE partitions have one replica and WITH_TWO_OR_MORE have more"
40+
exit 0
41+
42+
quit-on-nonzero-exit.sh: |-
43+
exec >> /tmp/testlog
44+
exec 2>&1
45+
46+
exit 0
47+
---
48+
apiVersion: apps/v1beta2
49+
kind: ReplicaSet
50+
metadata:
51+
name: replication-config
52+
namespace: test-kafka
53+
spec:
54+
# Note that this test sets a consumer group, but asserts assume that the tests gets its own messages
55+
replicas: 1
56+
selector:
57+
matchLabels:
58+
test-target: kafka-replication-config
59+
test-type: readiness
60+
template:
61+
metadata:
62+
labels:
63+
test-target: kafka-replication-config
64+
test-type: readiness
65+
spec:
66+
containers:
67+
- name: testcase
68+
image: solsson/kafkacat@sha256:b32eedf936f3cde44cd164ddc77dfcf7565a8af4e357ff6de1abe4389ca530c9
69+
env:
70+
- name: BOOTSTRAP
71+
value: bootstrap.kafka:9092
72+
- name: MAX_SINGLE_REPLICA_PARTITIONS
73+
value: "0"
74+
command:
75+
- /bin/bash
76+
- -e
77+
- /test/setup.sh
78+
readinessProbe:
79+
exec:
80+
command:
81+
- /bin/bash
82+
- -e
83+
- /test/test.sh
84+
initialDelaySeconds: 30
85+
periodSeconds: 60
86+
livenessProbe:
87+
exec:
88+
command:
89+
- /bin/bash
90+
- -e
91+
- /test/quit-on-nonzero-exit.sh
92+
volumeMounts:
93+
- name: config
94+
mountPath: /test
95+
volumes:
96+
- name: config
97+
configMap:
98+
name: replication-config

yahoo-kafka-manager/kafka-manager.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ spec:
1515
spec:
1616
containers:
1717
- name: kafka-manager
18-
image: solsson/kafka-manager@sha256:e07b5c50b02c761b3471ebb62ede88afc0625e325fe428316e32fec7f227ff9b
18+
image: solsson/kafka-manager@sha256:5db7d54cdb642ec5a92f37a869fdcf2aa479b2552e900b2d2b83b38a1806c2de
1919
ports:
2020
- containerPort: 80
2121
env:

0 commit comments

Comments
 (0)