Skip to content

Commit 03d45f9

Browse files
authored
kafka: switch to apache/kafka container (#28077)
1 parent 8264ff0 commit 03d45f9

File tree

14 files changed

+57
-209
lines changed

14 files changed

+57
-209
lines changed

generators/app/__snapshots__/generator.spec.ts.snap

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -329,12 +329,11 @@ exports[`generator - app with default config should match snapshot 1`] = `
329329
"devServerPort": 4200,
330330
"devServerPortProxy": 9000,
331331
"dockerContainers": {
332+
"apache/kafka-native": "apache-kafka-native-placeholder",
332333
"apachepulsar/pulsar": "apachepulsar-pulsar-placeholder",
333334
"cassandra": "cassandra-placeholder",
334335
"cassandraImage": "cassandra-image-placeholder",
335336
"cassandraTag": "cassandra-tag-placeholder",
336-
"confluentinc/cp-kafka": "confluentinc-cp-kafka-placeholder",
337-
"confluentinc/cp-zookeeper": "confluentinc-cp-zookeeper-placeholder",
338337
"consul": "consul-placeholder",
339338
"consulConfigLoader": "consul-config-loader-placeholder",
340339
"consulConfigLoaderImage": "consul-config-loader-image-placeholder",
@@ -449,9 +448,6 @@ exports[`generator - app with default config should match snapshot 1`] = `
449448
"zipkin": "zipkin-placeholder",
450449
"zipkinImage": "zipkin-image-placeholder",
451450
"zipkinTag": "zipkin-tag-placeholder",
452-
"zookeeper": "zookeeper-placeholder",
453-
"zookeeperImage": "zookeeper-image-placeholder",
454-
"zookeeperTag": "zookeeper-tag-placeholder",
455451
},
456452
"dockerServices": [
457453
"app",
@@ -999,12 +995,11 @@ exports[`generator - app with gateway should match snapshot 1`] = `
999995
"devServerPort": 4200,
1000996
"devServerPortProxy": 9000,
1001997
"dockerContainers": {
998+
"apache/kafka-native": "apache-kafka-native-placeholder",
1002999
"apachepulsar/pulsar": "apachepulsar-pulsar-placeholder",
10031000
"cassandra": "cassandra-placeholder",
10041001
"cassandraImage": "cassandra-image-placeholder",
10051002
"cassandraTag": "cassandra-tag-placeholder",
1006-
"confluentinc/cp-kafka": "confluentinc-cp-kafka-placeholder",
1007-
"confluentinc/cp-zookeeper": "confluentinc-cp-zookeeper-placeholder",
10081003
"consul": "consul-placeholder",
10091004
"consulConfigLoader": "consul-config-loader-placeholder",
10101005
"consulConfigLoaderImage": "consul-config-loader-image-placeholder",
@@ -1119,9 +1114,6 @@ exports[`generator - app with gateway should match snapshot 1`] = `
11191114
"zipkin": "zipkin-placeholder",
11201115
"zipkinImage": "zipkin-image-placeholder",
11211116
"zipkinTag": "zipkin-tag-placeholder",
1122-
"zookeeper": "zookeeper-placeholder",
1123-
"zookeeperImage": "zookeeper-image-placeholder",
1124-
"zookeeperTag": "zookeeper-tag-placeholder",
11251117
},
11261118
"dockerServices": [
11271119
"app",
@@ -1664,12 +1656,11 @@ exports[`generator - app with microservice should match snapshot 1`] = `
16641656
"devServerPort": undefined,
16651657
"devServerPortProxy": undefined,
16661658
"dockerContainers": {
1659+
"apache/kafka-native": "apache-kafka-native-placeholder",
16671660
"apachepulsar/pulsar": "apachepulsar-pulsar-placeholder",
16681661
"cassandra": "cassandra-placeholder",
16691662
"cassandraImage": "cassandra-image-placeholder",
16701663
"cassandraTag": "cassandra-tag-placeholder",
1671-
"confluentinc/cp-kafka": "confluentinc-cp-kafka-placeholder",
1672-
"confluentinc/cp-zookeeper": "confluentinc-cp-zookeeper-placeholder",
16731664
"consul": "consul-placeholder",
16741665
"consulConfigLoader": "consul-config-loader-placeholder",
16751666
"consulConfigLoaderImage": "consul-config-loader-image-placeholder",
@@ -1784,9 +1775,6 @@ exports[`generator - app with microservice should match snapshot 1`] = `
17841775
"zipkin": "zipkin-placeholder",
17851776
"zipkinImage": "zipkin-image-placeholder",
17861777
"zipkinTag": "zipkin-tag-placeholder",
1787-
"zookeeper": "zookeeper-placeholder",
1788-
"zookeeperImage": "zookeeper-image-placeholder",
1789-
"zookeeperTag": "zookeeper-tag-placeholder",
17901778
},
17911779
"dockerServices": [
17921780
"app",

generators/docker-compose/templates/README-DOCKER-COMPOSE.md.ejs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ Launch all your infrastructure by running: `docker compose up -d`.
3232
<%_ } _%>
3333
<%_ if (useKafka === true) { _%>
3434
- Kafka
35-
- Zookeeper
3635
<%_ } _%>
3736
<%_ if (usePulsar === true) { _%>
3837
- Pulsar

generators/docker-compose/templates/docker-compose.yml.ejs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,17 @@ services:
2121
<%- appsYaml[i] %>
2222
<%_ } _%>
2323
<%_ if (useKafka) { _%>
24-
zookeeper:
25-
image: <%- dockerContainers.zookeeper %>
26-
environment:
27-
ZOOKEEPER_CLIENT_PORT: 2181
28-
ZOOKEEPER_TICK_TIME: 2000
29-
ZOOKEEPER_SYNC_LIMIT: 2
3024
kafka:
3125
image: <%- dockerContainers.kafka %>
3226
environment:
27+
KAFKA_NODE_ID: 1
28+
KAFKA_PROCESS_ROLES: broker,controller
3329
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
34-
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
35-
KAFKA_BROKER_ID: 2
36-
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
30+
KAFKA_LISTENERS: PLAINTEXT://:9092,CONTROLLER://localhost:9093
31+
KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
32+
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT
33+
KAFKA_CONTROLLER_QUORUM_VOTERS: 1@localhost:9093
34+
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
3735
#ports:
3836
# - 9092:9092 # Uncomment to make Kafka available externally
3937
<%_ } _%>

generators/docker/__snapshots__/generator.spec.ts.snap

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,6 @@ services:
256256
extends:
257257
file: ./kafka.yml
258258
service: kafka
259-
zookeeper:
260-
extends:
261-
file: ./kafka.yml
262-
service: zookeeper
263259
",
264260
"stateCleared": "modified",
265261
},
@@ -365,10 +361,6 @@ services:
365361
extends:
366362
file: ./kafka.yml
367363
service: kafka
368-
zookeeper:
369-
extends:
370-
file: ./kafka.yml
371-
service: zookeeper
372364
",
373365
"stateCleared": "modified",
374366
},
@@ -743,10 +735,6 @@ services:
743735
extends:
744736
file: ./kafka.yml
745737
service: kafka
746-
zookeeper:
747-
extends:
748-
file: ./kafka.yml
749-
service: zookeeper
750738
",
751739
"stateCleared": "modified",
752740
},
@@ -856,10 +844,6 @@ services:
856844
extends:
857845
file: ./kafka.yml
858846
service: kafka
859-
zookeeper:
860-
extends:
861-
file: ./kafka.yml
862-
service: zookeeper
863847
",
864848
"stateCleared": "modified",
865849
},

generators/docker/generator.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,7 @@ export default class DockerGenerator extends BaseApplicationGenerator {
228228
);
229229
}
230230
if (application.dockerServices.includes('kafka')) {
231-
source.addDockerExtendedServiceToApplicationAndServices(
232-
{ serviceName: 'kafka' },
233-
{ serviceFile: './kafka.yml', serviceName: 'zookeeper' },
234-
);
231+
source.addDockerExtendedServiceToApplicationAndServices({ serviceName: 'kafka' });
235232
}
236233
},
237234

generators/docker/templates/docker/kafka.yml.ejs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,14 @@ services:
2626
ports:
2727
- 127.0.0.1:9092:9092
2828
environment:
29-
KAFKA_BROKER_ID: 1
30-
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
31-
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092
32-
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
33-
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
34-
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
35-
KAFKA_ADVERTISED_HOST_NAME: kafka
36-
<%_ if (backendTypeSpringBoot) { _%>
37-
labels:
38-
org.springframework.boot.ignore: true
39-
<%_ } _%>
40-
zookeeper:
41-
image: <%- dockerContainers.zookeeper %>
42-
environment:
43-
ZOOKEEPER_CLIENT_PORT: 2181
44-
ZOOKEEPER_TICK_TIME: 2000
29+
KAFKA_NODE_ID: 1
30+
KAFKA_PROCESS_ROLES: broker,controller
31+
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092
32+
KAFKA_LISTENERS: PLAINTEXT://:9092,CONTROLLER://localhost:9093
33+
KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
34+
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT
35+
KAFKA_CONTROLLER_QUORUM_VOTERS: 1@localhost:9093
36+
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
4537
<%_ if (backendTypeSpringBoot) { _%>
4638
labels:
4739
org.springframework.boot.ignore: true

generators/kubernetes-helm/__snapshots__/kubernetes.helm.spec.ts.snap

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ dependencies:
116116
"csvc-helm/templates/_helpers.tpl": {
117117
"contents": "{{/* vim: set filetype=mustache: */}}
118118
{{/*
119-
Kafka and zookeeper customisation
119+
Kafka customisation
120120
*/}}
121121
{{- define "kafka.name" -}}
122122
{{- default "jhipster-kafka" -}}
@@ -126,17 +126,6 @@ Kafka and zookeeper customisation
126126
{{- default "jhipster-kafka" -}}
127127
{{- end -}}
128128
129-
{{- define "zookeeper.name" -}}
130-
{{- default "jhipster-zookeeper" -}}
131-
{{- end -}}
132-
133-
{{- define "zookeeper.fullname" -}}
134-
{{- default "jhipster-zookeeper" -}}
135-
{{- end -}}
136-
137-
{{- define "kafka.zookeeper.fullname" -}}
138-
{{- default "jhipster-zookeeper" -}}
139-
{{- end -}}
140129
141130
",
142131
"stateCleared": "modified",
@@ -145,9 +134,6 @@ Kafka and zookeeper customisation
145134
"contents": "kafka:
146135
enabled: true
147136
replicas: 3
148-
zookeeper:
149-
enabled: true
150-
replicas: 3
151137
",
152138
"stateCleared": "modified",
153139
},

generators/kubernetes-helm/templates/csvc/helpers.tpl.ejs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{/* vim: set filetype=mustache: */}}
22
<%_ if (useKafka) { _%>
33
{{/*
4-
Kafka and zookeeper customisation
4+
Kafka customisation
55
*/}}
66
{{- define "kafka.name" -}}
77
{{- default "jhipster-kafka" -}}
@@ -11,17 +11,6 @@ Kafka and zookeeper customisation
1111
{{- default "jhipster-kafka" -}}
1212
{{- end -}}
1313

14-
{{- define "zookeeper.name" -}}
15-
{{- default "jhipster-zookeeper" -}}
16-
{{- end -}}
17-
18-
{{- define "zookeeper.fullname" -}}
19-
{{- default "jhipster-zookeeper" -}}
20-
{{- end -}}
21-
22-
{{- define "kafka.zookeeper.fullname" -}}
23-
{{- default "jhipster-zookeeper" -}}
24-
{{- end -}}
2514
<%_ } _%>
2615
<%_ if (monitoringPrometheus) { _%>
2716
{{/*

generators/kubernetes-helm/templates/csvc/values.yml.ejs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@ kafka:
66
podAnnotations:
77
sidecar.istio.io/inject: "false"
88
<%_ } _%>
9-
zookeeper:
10-
enabled: true
11-
replicas: 3
12-
<%_ if (istio) { _%>
13-
podAnnotations:
14-
sidecar.istio.io/inject: "false"
15-
<%_ } _%>
169
<%_ } _%>
1710
<%_ if (monitoringPrometheus) { _%>
1811
prometheus:

generators/kubernetes/__snapshots__/kubernetes.spec.ts.snap

Lines changed: 16 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,24 @@ spec:
203203
- name: kafka
204204
image: kafka-placeholder
205205
env:
206+
- name: KAFKA_NODE_ID
207+
value: 1
208+
- name: KAFKA_PROCESS_ROLES
209+
value: broker,controller
206210
- name: KAFKA_ADVERTISED_LISTENERS
207211
value: 'PLAINTEXT://jhipster-kafka.default.svc.cluster.local:9092'
208-
- name: KAFKA_ZOOKEEPER_CONNECT
209-
value: 'jhipster-zookeeper.default.svc.cluster.local:2181'
210-
- name: KAFKA_BROKER_ID
211-
value: '2'
212+
- name: KAFKA_LISTENERS
213+
value: PLAINTEXT://:9092,CONTROLLER://localhost:9093
214+
- name: KAFKA_CONTROLLER_LISTENER_NAMES
215+
value: CONTROLLER
216+
- name: KAFKA_LISTENER_SECURITY_PROTOCOL_MAP
217+
value: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT
218+
- name: KAFKA_CONTROLLER_QUORUM_VOTERS
219+
value: 1@localhost:9093
220+
- name: KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS
221+
value: 0
212222
- name: KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR
213-
value: '1'
223+
value: 1
214224
ports:
215225
- containerPort: 9092
216226
resources:
@@ -231,53 +241,7 @@ spec:
231241
app: jhipster-kafka
232242
ports:
233243
- port: 9092
234-
---
235-
apiVersion: apps/v1
236-
kind: Deployment
237-
metadata:
238-
name: jhipster-zookeeper
239-
namespace: default
240-
spec:
241-
replicas: 1
242-
selector:
243-
matchLabels:
244-
app: jhipster-zookeeper
245-
template:
246-
metadata:
247-
labels:
248-
app: jhipster-zookeeper
249-
spec:
250-
containers:
251-
- name: zookeeper
252-
image: zookeeper-placeholder
253-
env:
254-
- name: ZOOKEEPER_CLIENT_PORT
255-
value: '2181'
256-
- name: ZOOKEEPER_TICK_TIME
257-
value: '2000'
258-
- name: ZOOKEEPER_SYNC_LIMIT
259-
value: '2'
260-
ports:
261-
- containerPort: 2181
262-
resources:
263-
requests:
264-
memory: "512Mi"
265-
cpu: "500m"
266-
limits:
267-
memory: "1Gi"
268-
cpu: "1"
269-
---
270-
apiVersion: v1
271-
kind: Service
272-
metadata:
273-
name: jhipster-zookeeper
274-
namespace: default
275-
spec:
276-
selector:
277-
app: jhipster-zookeeper
278-
ports:
279-
- port: 2181
280-
",
244+
",
281245
"stateCleared": "modified",
282246
},
283247
"samplekafka-k8s/samplekafka-deployment.yml": {

0 commit comments

Comments
 (0)