Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Instant kraft demo #1124

Draft
wants to merge 3 commits into
base: 7.2.1-post
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
![image](images/confluent-logo-300-2.png)

* [Overview](#overview)
* [Where to Start](#where-to-start)
* [Confluent Cloud](#confluent-cloud)
* [Stream Processing](#stream-processing)
* [Data Pipelines](#data-pipelines)
* [Confluent Platform](#confluent-platform)
* [Build Your Own](#build-your-own)
* [Additional Demos](#additional-demos)
- [Overview](#overview)
- [Where to start](#where-to-start)
- [Confluent Cloud](#confluent-cloud)
- [Stream Processing](#stream-processing)
- [Data Pipelines](#data-pipelines)
- [Confluent Platform](#confluent-platform)
- [Build Your Own](#build-your-own)
- [Additional Demos](#additional-demos)


# Overview
Expand Down Expand Up @@ -61,17 +61,17 @@ You can find the documentation and instructions for all Confluent Cloud demos at

# Confluent Platform

| Demo | Local | Docker | Description
| ------------------------------------------ | ----- | ------ | ---------------------------------------------------------------------------
| [Avro](clients/README.md) | [Y](clients/README.md) | N | Client applications using Avro and Confluent Schema Registry <br><img src="https://www.confluent.io/wp-content/uploads/dwg_SchemaReg_howitworks.png" width="420">
| [CP Demo](https://github.com/confluentinc/cp-demo) | N | [Y](https://github.com/confluentinc/cp-demo) | [Confluent Platform demo](https://docs.confluent.io/platform/current/tutorials/cp-demo/docs/index.html?utm_source=github&utm_medium=demo&utm_campaign=ch.examples_type.community_content.top) (`cp-demo`) with a playbook for Kafka event streaming ETL deployments <br><img src="https://github.com/confluentinc/cp-demo/blob/7.2.1-post/docs/images/cp-demo-overview.jpg" width="420">
| [Kubernetes](kubernetes/README.md) | N | [Y](kubernetes/README.md) | Demonstrations of Confluent Platform deployments using the [Confluent Operator](https://docs.confluent.io/operator/current/overview.html?utm_source=github&utm_medium=demo&utm_campaign=ch.examples_type.community_content.top) <br><img src="kubernetes/docs/images/operator.png" width="420">
| [Multi Datacenter](multi-datacenter/README.md) | N | [Y](multi-datacenter/README.md) | Active-active multi-datacenter design with two instances of Confluent Replicator copying data bidirectionally between the datacenters <br><img src="https://docs.confluent.io/platform/current/_images/mdc-level-1.png" width="420">
| [Multi-Region Clusters](multiregion/README.md) | N | [Y](multiregion/README.md) | Multi-Region clusters (MRC) with follower fetching, observers, and replica placement<br><img src="multiregion/docs/images/multi-region-topic-replicas-v2.png" width="420">
| [Quickstart](cp-quickstart/README.md) | [Y](cp-quickstart/README.md) | [Y](cp-quickstart/README.md) | Automated version of the [Confluent Quickstart](https://docs.confluent.io/platform/current/quickstart/index.html?utm_source=github&utm_medium=demo&utm_campaign=ch.examples_type.community_content.top): for Confluent Platform on local install or Docker, community version, and Confluent Cloud <br><img src="cp-quickstart/images/quickstart.png" width="420">
| [Role-Based Access Control](security/rbac/README.md) | Y | Y | Role-based Access Control (RBAC) provides granular privileges for users and service accounts <br><img src="https://docs.confluent.io/platform/current/_images/rbac-overview.png" width="450">
| [Replicator Security](replicator-security/README.md) | N | [Y](replicator-security/README.md) | Demos of various security configurations supported by Confluent Replicator and examples of how to implement them <br><img src="images/replicator-security.png" width="300">

| Demo | Local | Docker | Description |
|------------------------------------------------------|------------------------------|----------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Avro](clients/README.md) | [Y](clients/README.md) | N | Client applications using Avro and Confluent Schema Registry <br><img src="https://www.confluent.io/wp-content/uploads/dwg_SchemaReg_howitworks.png" width="420"> |
| [CP Demo](https://github.com/confluentinc/cp-demo) | N | [Y](https://github.com/confluentinc/cp-demo) | [Confluent Platform demo](https://docs.confluent.io/platform/current/tutorials/cp-demo/docs/index.html?utm_source=github&utm_medium=demo&utm_campaign=ch.examples_type.community_content.top) (`cp-demo`) with a playbook for Kafka event streaming ETL deployments <br><img src="https://github.com/confluentinc/cp-demo/blob/7.2.1-post/docs/images/cp-demo-overview.jpg" width="420"> |
| [Kubernetes](kubernetes/README.md) | N | [Y](kubernetes/README.md) | Demonstrations of Confluent Platform deployments using the [Confluent Operator](https://docs.confluent.io/operator/current/overview.html?utm_source=github&utm_medium=demo&utm_campaign=ch.examples_type.community_content.top) <br><img src="kubernetes/docs/images/operator.png" width="420"> |
| [Multi Datacenter](multi-datacenter/README.md) | N | [Y](multi-datacenter/README.md) | Active-active multi-datacenter design with two instances of Confluent Replicator copying data bidirectionally between the datacenters <br><img src="https://docs.confluent.io/platform/current/_images/mdc-level-1.png" width="420"> |
| [Multi-Region Clusters](multiregion/README.md) | N | [Y](multiregion/README.md) | Multi-Region clusters (MRC) with follower fetching, observers, and replica placement<br><img src="multiregion/docs/images/multi-region-topic-replicas-v2.png" width="420"> |
| [Quickstart](cp-quickstart/README.md) | [Y](cp-quickstart/README.md) | [Y](cp-quickstart/README.md) | Automated version of the [Confluent Quickstart](https://docs.confluent.io/platform/current/quickstart/index.html?utm_source=github&utm_medium=demo&utm_campaign=ch.examples_type.community_content.top): for Confluent Platform on local install or Docker, community version, and Confluent Cloud <br><img src="cp-quickstart/images/quickstart.png" width="420"> |
| [Role-Based Access Control](security/rbac/README.md) | Y | Y | Role-based Access Control (RBAC) provides granular privileges for users and service accounts <br><img src="https://docs.confluent.io/platform/current/_images/rbac-overview.png" width="450"> |
| [Replicator Security](replicator-security/README.md) | N | [Y](replicator-security/README.md) | Demos of various security configurations supported by Confluent Replicator and examples of how to implement them <br><img src="images/replicator-security.png" width="300"> |
| [Instant KRaft](instant-kraft/README.md) | Y | [Y](instant-kraft/README.md) | Get started with KRaft mode in Kafka in just a few minutes. Explore KRaft metadata. Note that KRaft is not yet supported in Confluent Platform.

# Build Your Own

Expand Down
56 changes: 56 additions & 0 deletions instant-kraft/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Instant KRaft Demo
Let's make some delicious instant KRaft
___
.'O o'-._
/ O o_.-`|
/O_.-' O |
|O o O .-`
|o O_.-'
'--`
Comment on lines +3 to +9
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might need to be in a code block to appear proper cheesy.


## Step 1
```
$ git clone https://github.com/confluentinc/examples.git && cd examples/instant-kraft

$ docker compose up
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For better or worse, our examples seem to usually use docker-compose up -d, i.e. launch detached/daemonized, so the current shell isn't left bound to the command and tailing the logs. Downside is that you have to docker logs or docker-compose logs to see any errors or interesting logging.

Up to you whether you want the -d here, but note that users might struggle with losing their shell prompt, and also unintentionally kill with CTRL-C.

```

That's it! One container, one process, doing the the broker and controller work. No Zookeeper.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think ZooKeeper (camel case) is standard.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doing the the broker and controller work

Remove duplicate "the" and reword. Maybe

One container, one process performing both broker and controller/quorum roles.

The key server configure to enable KRaft is the `process.roles`. Here we have the same node doing both the broker and quorum conroller work. Note that this is ok for local development, but in production you should have seperate nodes for the broker and controller quorum nodes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs rewording.

The key server configuration for enabling KRaft is process.roles.


```
KAFKA_PROCESS_ROLES: 'broker,controller'
```

## Step 2
Start streaming

```
$ docker compose exec broker kafka-topics --create --topic zookeeper-vacation-ideas --bootstrap-server localhost:9092

$ docker-compose exec broker kafka-producer-perf-test --topic zookeeper-vacation-ideas \
Comment on lines +29 to +31
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commands used include both docker compose and docker-compose. The former I think relies on later versions of Docker with either Compose included, or via a command-plugins capability.

Maybe we should stick to one. I think our formal docs lean towards docker-compose.

--num-records 200000 \
--record-size 50 \
--throughput -1 \
--producer-props \
acks=all \
bootstrap.servers=localhost:9092 \
compression.type=none \
batch.size=8196
```

## Step 3
Explore the cluster using the new kafka metadata command line tool.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we refer to it inline by name? I don't mind, just asking: kafka-metadata-shell


```
$ docker-compose exec broker kafka-metadata-shell --snapshot /tmp/kraft-combined-logs/__cluster_metadata-0/00000000000000000000.log

# use the metadata shell to explore the quorum
>> ls metadataQuorum

>> cat metadataQuorum/leader
```

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we mention CTRL-D to exit the REPL?

Note: the `update_run.sh` is to get around some checks in the cp-kafka docker image. There are plans to change those checks in the future.

The scipt also formats the storage volumes with a random uuid for the cluster. Formatting kafka storage is very important in production environments. See the AK documentation for more information.
30 changes: 30 additions & 0 deletions instant-kraft/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
version: '2'
services:
broker:
image: confluentinc/cp-kafka:latest
hostname: broker
container_name: broker
ports:
- "9092:9092"
- "9101:9101"
environment:
KAFKA_BROKER_ID: 1
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: 'CONTROLLER:PLAINTEXT,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_TRANSACTION_STATE_LOG_MIN_ISR: 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
KAFKA_JMX_PORT: 9101
KAFKA_JMX_HOSTNAME: localhost
KAFKA_PROCESS_ROLES: 'broker,controller'
KAFKA_NODE_ID: 1
KAFKA_CONTROLLER_QUORUM_VOTERS: '1@broker:29093'
KAFKA_LISTENERS: 'PLAINTEXT://broker:29092,CONTROLLER://broker:29093,PLAINTEXT_HOST://0.0.0.0:9092'
KAFKA_INTER_BROKER_LISTENER_NAME: 'PLAINTEXT'
KAFKA_CONTROLLER_LISTENER_NAMES: 'CONTROLLER'
KAFKA_LOG_DIRS: '/tmp/kraft-combined-logs'
volumes:
- ./update_run.sh:/tmp/update_run.sh
command: "bash -c 'if [ ! -f /tmp/update_run.sh ]; then echo \"ERROR: Did you forget the update_run.sh file that came with this docker-compose.yml file?\" && exit 1 ; else /tmp/update_run.sh && /etc/confluent/docker/run ; fi'"
10 changes: 10 additions & 0 deletions instant-kraft/update_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

# Docker workaround: Remove check for KAFKA_ZOOKEEPER_CONNECT parameter
sed -i '/KAFKA_ZOOKEEPER_CONNECT/d' /etc/confluent/docker/configure

# Docker workaround: Ignore cub zk-ready
sed -i 's/cub zk-ready/echo ignore zk-ready/' /etc/confluent/docker/ensure

# KRaft required step: Format the storage directory with a new cluster ID
echo "kafka-storage format --ignore-formatted -t $(kafka-storage random-uuid) -c /etc/kafka/kafka.properties" >> /etc/confluent/docker/ensure