Start streaming
Before you can start streaming with Redpanda, install the software.
-
To install Redpanda on a one-node cluster for development and testing purposes, see the installation instructions for your operating system.
-
To install Redpanda on a production cluster, see Deploying Redpanda for Production.
Streaming with rpk
rpk
is a CLI tool you can use to work with your Redpanda nodes. Refer to rpk Commands for more information about rpk
.
Here are some sample commands to produce and consume streams:
-
Docker
-
Linux
-
Kubernetes
Create a topic called twitch_chat
:
docker exec -it redpanda-1 \
rpk topic create twitch_chat --brokers=localhost:9092
Output:
TOPIC STATUS
twitch_chat OK
Produce a message into the topic:
docker exec -it redpanda-1 \
rpk topic produce twitch_chat --brokers=localhost:9092
Enter a message:
Pandas are fabulous!
Output:
Produced to partition 0 at offset 0 with timestamp 1663282629789.
Click ctrl-d
(or ctrl-z
on Windows) to finish sending messages to the topic.
Consume one message from the topic:
docker exec -it redpanda-1 \
rpk topic consume twitch_chat --num 1 --brokers=localhost:9092
Each message is shown with its metadata, like this:
{
"topic": "twitch_chat",
"value": "Pandas are fabulous!",
"timestamp": 1663282629789,
"partition": 0,
"offset": 0
}
You can delete your topic by running:
docker exec -it redpanda-1 \
rpk topic delete twitch_chat --brokers=localhost:9092
Output:
TOPIC STATUS
twitch_chat OK
Create a topic called twitch_chat
:
rpk topic create twitch_chat
Output:
TOPIC STATUS
twitch_chat OK
Produce a message into the topic:
rpk topic produce twitch_chat
Enter a message:
Pandas are fabulous!
Output:
Produced to partition 0 at offset 0 with timestamp 1663282629795.
Click ctrl-d
(or ctrl-z
on Windows) to finish sending messages to the topic.
Consume one message from the topic:
rpk topic consume twitch_chat --num 1
Each message is shown with its metadata, like this:
{
"topic": "twitch_chat",
"value": "Pandas are fabulous!",
"timestamp": 1663282629795,
"partition": 0,
"offset": 0
}
You can delete your topic by running:
rpk topic delete twitch_chat
Output:
TOPIC STATUS
twitch_chat OK
Set up an alias to simplify these commands:
alias rpk="kubectl -n redpanda exec -ti redpanda-0 -c redpanda -- rpk --brokers=redpanda-0.redpanda.redpanda.svc.cluster.local.:9093"
Create a topic called twitch_chat
:
rpk topic create twitch_chat
Output:
TOPIC STATUS
twitch_chat OK
Describe the topic:
rpk topic describe twitch_chat
Output:
SUMMARY
=======
NAME twitch_chat
PARTITIONS 1
REPLICAS 1
CONFIGS
=======
KEY VALUE SOURCE
cleanup.policy delete DYNAMIC_TOPIC_CONFIG
compression.type producer DEFAULT_CONFIG
message.timestamp.type CreateTime DEFAULT_CONFIG
partition_count 1 DYNAMIC_TOPIC_CONFIG
redpanda.datapolicy function_name: script_name: DEFAULT_CONFIG
redpanda.remote.read false DEFAULT_CONFIG
redpanda.remote.write false DEFAULT_CONFIG
replication_factor 1 DYNAMIC_TOPIC_CONFIG
retention.bytes -1 DEFAULT_CONFIG
retention.ms 604800000 DEFAULT_CONFIG
segment.bytes 1073741824 DEFAULT_CONFIG
Produce a message into the topic:
rpk topic produce twitch_chat
Enter a message:
Pandas are fabulous!
Output:
Produced to partition 0 at offset 0 with timestamp 1663282629789.
Click ctrl-d
(or ctrl-z
on Windows) to finish sending messages to the topic.
Consume one message from the topic:
rpk topic consume twitch_chat --num 1
Each message is shown with its metadata, like this:
{
"topic": "twitch_chat",
"value": "Pandas are fabulous!",
"timestamp": 1663282629789,
"partition": 0,
"offset": 0
}
You can delete your topic by running:
rpk topic delete twitch_chat
Output:
TOPIC STATUS
twitch_chat OK