Kafka REST Proxy

The Kafka REST Proxy provides a RESTful interface to a Kafka cluster.

⚠️ Use this when you really need a rest interface since it is usually more complex than using conventional kafka clients.

Run Kafka REST Proxy:

cd kafka-rest
docker compose up -d
cd ..

After a few seconds:

http :8082/brokers

Create topics:

cd kafka-rest
http :8082/topics/kafka-rest.test Content-Type:application/vnd.kafka.json.v2+json records:='[{ "key": "test", "value": "test" }]'
http :8082/topics/kafka-rest.users Content-Type:application/vnd.kafka.avro.v2+json < requests/produce-avro-message.json
cd ..

Docker Compose

services:
  kafka-rest:
    image: confluentinc/cp-kafka-rest:${VERSION}
    environment:
      KAFKA_REST_BOOTSTRAP_SERVERS: kafka1:9092,kafka2:9092,kafka3:9092
      KAFKA_REST_SCHEMA_REGISTRY_URL: http://schema-registry:8081
    ports:
      - "8082:8082"
    restart: on-failure
    healthcheck:
      test: curl http://localhost:8082
      interval: 30s
      timeout: 30s
      retries: 5
      start_period: 30s

networks:
  default:
    external: true
    name: kafka-sandbox_network

Requests

requests/produce-avro-message.json

{
  "value_schema": "{\"type\": \"record\", \"name\": \"User\", \"fields\": [{\"name\": \"name\", \"type\": \"string\"}]}",
  "records": [
    {
      "value": {
        "name": "John Doe"
      }
    }
  ]
}