Redpanda CLI Quickstart

This guide shows how to run the Redpanda CLI, rpk, for basic Redpanda tasks, including creating, producing to, describing, and deleting topics, as well as consuming records and managing consumer groups. Follow these examples to quickly become familiar with rpk commands.

Consider creating an rpk profile to simplify your development experience with multiple Redpanda clusters by saving and reusing configurations for different clusters. For more information, see About rpk profiles.

Pre-requisites

Create a topic

To start streaming data, first create a topic as the destination for your records:

rpk topic create tutorial
bash

Output:

TOPIC     STATUS
tutorial  OK
bash

Produce records to a topic

Produce records to the topic. Downstream consumers will then be able to read these records. To exit the producer session, press Ctrl+C:

rpk topic produce tutorial
bash

Additional input:

hello
world
bash

Output:

Produced to partition 0 at offset 0 with timestamp 1734640650348.
Produced to partition 0 at offset 1 with timestamp 1734640653558.
bash

Get a description of a topic

Check the topic’s configuration and status to ensure that it’s ready for use:

rpk topic describe tutorial
bash

Output:

SUMMARY
=======
NAME        tutorial
PARTITIONS  1
REPLICAS    1

CONFIGS
=======
KEY                                   VALUE       SOURCE
cleanup.policy                        delete      DEFAULT_CONFIG
compression.type                      producer    DEFAULT_CONFIG
delete.retention.ms                   -1          DEFAULT_CONFIG
flush.bytes                           262144      DEFAULT_CONFIG
flush.ms                              100         DEFAULT_CONFIG
initial.retention.local.target.bytes  -1          DEFAULT_CONFIG
initial.retention.local.target.ms     -1          DEFAULT_CONFIG
max.message.bytes                     1048576     DEFAULT_CONFIG
message.timestamp.type                CreateTime  DEFAULT_CONFIG
redpanda.iceberg.delete               true        DEFAULT_CONFIG
redpanda.iceberg.mode                 disabled    DEFAULT_CONFIG
redpanda.leaders.preference           none        DEFAULT_CONFIG
redpanda.remote.delete                true        DEFAULT_CONFIG
redpanda.remote.read                  false       DEFAULT_CONFIG
redpanda.remote.write                 false       DEFAULT_CONFIG
retention.bytes                       -1          DEFAULT_CONFIG
retention.local.target.bytes          -1          DEFAULT_CONFIG
retention.local.target.ms             86400000    DEFAULT_CONFIG
retention.ms                          604800000   DEFAULT_CONFIG
segment.bytes                         134217728   DEFAULT_CONFIG
segment.ms                            1209600000  DEFAULT_CONFIG
write.caching                         true        DEFAULT_CONFIG
bash

Consume records from a topic

Consume records from the topic:

rpk topic consume tutorial
bash

Output:

{ "topic": "tutorial", "value": "hello", "timestamp": 1678807229837, "partition": 0, "offset": 0 }
{ "topic": "tutorial", "value": "world", "timestamp": 1678807232413, "partition": 0, "offset": 1 }
json

Consume from an offset, where 2 is not inclusive:

rpk topic consume tutorial --offset 0:2
bash

Output:

{ "topic": "tutorial", "value": "hello", "timestamp": 1678807229837, "partition": 0, "offset": 0 }
{ "topic": "tutorial", "value": "world", "timestamp": 1678807232413, "partition": 0, "offset": 1 }
json

Create a consumer group and consume topics

Organize consumers into groups to share workloads and balance consumption:

rpk topic consume tutorial --group tutorial-group
bash
The consumer group is created when you start consuming from the topic.

Output:

{
  "topic": "tutorial",
  "value": "hello",
  "timestamp": 1734640650348,
  "partition": 0,
  "offset": 0
}
{
  "topic": "tutorial",
  "value": "world",
  "timestamp": 1734640653558,
  "partition": 0,
  "offset": 1
}
json

List all consumer groups

List available consumer groups in your cluster:

rpk group list
bash

Output:

BROKER  GROUP           STATE
0       tutorial-group  Empty
bash

Get a description of a consumer group

View details about the consumer group’s state, coordinator, members, and offsets:

rpk group describe tutorial-group
bash

Output:

GROUP        tutorial-group
COORDINATOR  0
STATE        Empty
BALANCER
MEMBERS      0
TOTAL-LAG    0

TOPIC     PARTITION  CURRENT-OFFSET  LOG-START-OFFSET  LOG-END-OFFSET  LAG   MEMBER-ID  CLIENT-ID  HOST
tutorial  0          2               0                 2               0
bash

Delete a consumer group

Clean up by removing the tutorial-group consumer group:

rpk group delete tutorial-group
bash

Output:

GROUP           STATUS
tutorial-group  OK
bash

Delete a topic

Clean up by removing the tutorial topic:

rpk topic delete tutorial
bash

Output:

TOPIC     STATUS
tutorial  OK
bash

Next steps

  • To generate a profile to save and reuse configurations for different Redpanda clusters, see About rpk profiles.

  • For the complete list of rpk commands and their syntax, see the rpk Command Reference.