Skip to content

Commit

Permalink
[kafka] build kafka image (open-telemetry#617)
Browse files Browse the repository at this point in the history
* build kafka image

Signed-off-by: Pierre Tessier <pierre@pierretessier.com>

* build kafka image

Signed-off-by: Pierre Tessier <pierre@pierretessier.com>

* build kafka image

Signed-off-by: Pierre Tessier <pierre@pierretessier.com>

* build kafka image

Signed-off-by: Pierre Tessier <pierre@pierretessier.com>

* build kafka image

Signed-off-by: Pierre Tessier <pierre@pierretessier.com>

Signed-off-by: Pierre Tessier <pierre@pierretessier.com>
  • Loading branch information
puckpuck committed Dec 8, 2022
1 parent 5c06d52 commit d8892f5
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 21 deletions.
1 change: 0 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,5 @@ JAEGER_SERVICE_HOST=jaeger
# Kafka
KAFKA_SERVICE_PORT=9092
KAFKA_SERVICE_ADDR=kafka:${KAFKA_SERVICE_PORT}
ZOOKEEPER_SERVICE_PORT=2181

ENV_PLATFORM=local
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,5 @@ significant modifications will be credited to OpenTelemetry Authors.
([#615](https://github.com/open-telemetry/opentelemetry-demo/pull/615))
* Add tracing to Envoy (frontend-proxy)
([#613](https://github.com/open-telemetry/opentelemetry-demo/pull/613))
* Build Kafka image
([#617](https://github.com/open-telemetry/opentelemetry-demo/pull/617))
32 changes: 12 additions & 20 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ services:
deploy:
resources:
limits:
memory: 300M
memory: 20M
restart: always
environment:
- KAFKA_SERVICE_ADDR
Expand Down Expand Up @@ -525,28 +525,20 @@ services:

# Kafka used by Checkout, Accounting, and Fraud Detection services
kafka:
image: confluentinc/cp-kafka:7.2.2-1-ubi8
hostname: kafka
image: ${IMAGE_NAME}:${IMAGE_VERSION}-kafka
container_name: kafka
build:
context: ./
dockerfile: ./src/kafka/Dockerfile
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-kafka
deploy:
resources:
limits:
memory: 600M
restart: always
environment:
KAFKA_LISTENERS: PLAINTEXT://kafka:9092,CONTROLLER://kafka:9093
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
KAFKA_PROCESS_ROLES: 'controller,broker'
KAFKA_NODE_ID: 1
KAFKA_CONTROLLER_QUORUM_VOTERS: '1@kafka:9093'
KAFKA_METADATA_LOG_SEGMENT_MS: 15000
KAFKA_METADATA_MAX_RETENTION_MS: 1200000
KAFKA_METADATA_LOG_MAX_RECORD_BYTES_BETWEEN_SNAPSHOTS: 2800
KAFKA_AUTO_CREATE_TOPICS_ENABLE: true
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
volumes:
- ./src/kafka/update_run.sh:/tmp/update_run.sh
- ./src/kafka/clusterID:/tmp/clusterID
command: "bash -c 'ls -lh /tmp && /tmp/update_run.sh && /etc/confluent/docker/run'"
logging: *logging
healthcheck:
test: nc -z kafka 9092
Expand Down
22 changes: 22 additions & 0 deletions src/kafka/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM confluentinc/cp-kafka:latest-ubi8

USER appuser
WORKDIR /tmp
COPY ./src/kafka/clusterID clusterID
COPY ./src/kafka/update_run.sh update_run.sh

ENV KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092,CONTROLLER://0.0.0.0:9093
ENV KAFKA_CONTROLLER_QUORUM_VOTERS='1@0.0.0.0:9093'
ENV KAFKA_CONTROLLER_LISTENER_NAMES=CONTROLLER
ENV KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT
ENV KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS=0
ENV KAFKA_PROCESS_ROLES=controller,broker
ENV KAFKA_NODE_ID=1
ENV KAFKA_METADATA_LOG_SEGMENT_MS=15000
ENV KAFKA_METADATA_MAX_RETENTION_MS=1200000
ENV KAFKA_METADATA_LOG_MAX_RECORD_BYTES_BETWEEN_SNAPSHOTS=2800
ENV KAFKA_AUTO_CREATE_TOPICS_ENABLE=true
ENV KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1
ENV KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR=1

ENTRYPOINT ["/bin/sh", "-c", "ls -lh /tmp && /tmp/update_run.sh && /etc/confluent/docker/run"]
10 changes: 10 additions & 0 deletions src/kafka/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Kafka

This is used as a message queue service to connect the checkout service with
the accounting and fraud detection services.

## KRaft: Kafka without ZooKeeper

Kafka is run in KRaft mode. The `update_run.sh` script is used to configure
the system to run Kafka in this mode. Environment variables are substituted at
deploy-time.

0 comments on commit d8892f5

Please sign in to comment.