Skip to content

Instantly share code, notes, and snippets.

@christophschubert
Created August 9, 2023 09:34
Show Gist options
  • Save christophschubert/b09eb7e4b7751b211eafd36193489e58 to your computer and use it in GitHub Desktop.
Save christophschubert/b09eb7e4b7751b211eafd36193489e58 to your computer and use it in GitHub Desktop.
Docker compose environment to start Confluent REST Proxy and produce some message using JSON

Docker compose environment with Confluent REST Proxy and Control Center

Usage

docker compose up -d 
# please be patient...
curl -X POST -d @sample_payload.json -H "Content-Type: application/vnd.kafka.json.v2+json" http://localhost:8082/topics/test

In Control Center UI, navigate to 'controlcenter.cluster' -> 'Topics' -> 'test' -> 'Messages' and enter 0 and choose partition 0 in the offsets field

---
version: '2'
services:
zookeeper:
image: confluentinc/cp-zookeeper:7.4.0
hostname: zookeeper
container_name: zookeeper
ports:
- "2181:2181"
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
broker:
image: confluentinc/cp-server:7.4.0
hostname: broker
container_name: broker
depends_on:
- zookeeper
ports:
- "9092:9092"
- "9101:9101"
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://broker:29092,PLAINTEXT_HOST://localhost:9092
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
KAFKA_CONFLUENT_LICENSE_TOPIC_REPLICATION_FACTOR: 1
KAFKA_CONFLUENT_BALANCER_TOPIC_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
CONFLUENT_SUPPORT_CUSTOMER_ID: 'anonymous'
control-center:
image: confluentinc/cp-enterprise-control-center:7.4.0
hostname: control-center
container_name: control-center
depends_on:
- broker
ports:
- "9021:9021"
environment:
CONTROL_CENTER_BOOTSTRAP_SERVERS: 'broker:29092'
CONTROL_CENTER_REPLICATION_FACTOR: 1
CONTROL_CENTER_INTERNAL_TOPICS_PARTITIONS: 1
CONTROL_CENTER_MONITORING_INTERCEPTOR_TOPIC_PARTITIONS: 1
CONFLUENT_METRICS_TOPIC_REPLICATION: 1
CONTROL_CENTER_MODE_ENABLE: management
PORT: 9021
rest-proxy:
image: confluentinc/cp-kafka-rest:7.4.0
depends_on:
- broker
ports:
- 8082:8082
hostname: rest-proxy
container_name: rest-proxy
environment:
KAFKA_REST_HOST_NAME: rest-proxy
KAFKA_REST_BOOTSTRAP_SERVERS: 'broker:29092'
KAFKA_REST_LISTENERS: "http://0.0.0.0:8082"
{
"records": [
{
"key": "test-key",
"value": "test-value-with-key"
},
{
"value": "test-value-without-key"
},
{
"value": {"name": "Fred", "id": 17}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment