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

DOC-31 add rpk tutorial #935

Merged
merged 17 commits into from
Jan 28, 2025
1 change: 1 addition & 0 deletions modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
** xref:get-started:quickstarts.adoc[Quickstarts]
*** xref:get-started:quick-start.adoc[Redpanda Self-Managed]
*** xref:console:quickstart.adoc[Redpanda Console]
*** xref:get-started:rpk-quickstart.adoc[]
*** xref:get-started:docker-compose-labs.adoc[Docker Compose Labs]
** xref:get-started:licensing/index.adoc[Redpanda Licensing]
*** xref:get-started:licensing/overview.adoc[Editions and Enterprise Features]
Expand Down
5 changes: 4 additions & 1 deletion modules/get-started/pages/intro-to-rpk.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ After you install `rpk`, you can use it to:
* Set up access control lists (ACLs) and other security features
* Create topics, produce to topics, and consume from topics

See also: xref:get-started:rpk-install.adoc[]
See also:
* xref:get-started:rpk-install.adoc[]
* xref:get-started:config-rpk-profile.adoc[]
* xref:get-started:rpk-quickstart.adoc[]

== Specify command properties

Expand Down
3 changes: 2 additions & 1 deletion modules/get-started/pages/rpk-install.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ include::get-started:partial$install-rpk-macos.adoc[]

== Next steps

For a list of `rpk` commands and their syntax, see the xref:reference:rpk/index.adoc[rpk reference].
Explore rpk with the xref:rpk-quickstart.adoc[] guide.
For the complete list of `rpk` commands and their syntax, see the xref:reference:rpk/index.adoc[rpk reference].

// end::single-source[]
244 changes: 244 additions & 0 deletions modules/get-started/pages/rpk-quickstart.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
= Redpanda CLI Quickstart
:page-categories: rpk
:description: pass:q[Quickly become familiar with `rpk` commands for basic Redpanda tasks, including creating, producing to, describing, and deleting topics, as well as consuming records and managing consumer groups.]
// Do not put page aliases in the single-sourced content
// tag::single-source[]

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

The intro should say something about make sure you have rpk installed, or a prereq to install rpk with link: https://deploy-preview-935--redpanda-docs-preview.netlify.app/current/get-started/rpk-install/

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 xref:get-started:config-rpk-profile.adoc#about-rpk-profiles[About rpk profiles].

== Create a topic

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

[source,bash]
----
rpk topic create tutorial
----

Output:
[source,bash]
----
TOPIC STATUS
tutorial OK
----

See xref:reference:rpk/rpk-topic/rpk-topic-create.adoc[].

== 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`:

[source,bash]
----
rpk topic produce tutorial
----

Additional input:
[source,bash]
----
hello
world
----

Output:
[source,bash]
----
Produced to partition 0 at offset 0 with timestamp 1734640650348.
Produced to partition 0 at offset 1 with timestamp 1734640653558.
----

See xref:reference:rpk/rpk-topic/rpk-topic-produce.adoc[].

== Get a description of a topic

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

[source,bash]
----
rpk topic describe tutorial
----

Output:
[source,bash]
----
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
----

See xref:reference:rpk/rpk-topic/rpk-topic-describe.adoc[].

== Consume records from a topic

Consume records from the topic:

[source,bash]
----
rpk topic consume tutorial
----

Output:
[source,json]
----
{ "topic": "tutorial", "value": "hello", "timestamp": 1678807229837, "partition": 0, "offset": 0 }
{ "topic": "tutorial", "value": "world", "timestamp": 1678807232413, "partition": 0, "offset": 1 }
----

Consume from an offset, where `2` is not inclusive:
[source,bash]
----
rpk topic consume tutorial --offset 0:2
----
Output:
[source,json]
----
{ "topic": "tutorial", "value": "hello", "timestamp": 1678807229837, "partition": 0, "offset": 0 }
{ "topic": "tutorial", "value": "world", "timestamp": 1678807232413, "partition": 0, "offset": 1 }
----

See xref:reference:rpk/rpk-topic/rpk-topic-consume.adoc[].

== Create a consumer group and consume topics

Organize consumers into groups to share workloads and balance consumption:

[source,bash]
----
rpk topic consume tutorial --group tutorial-group
----

NOTE: The consumer group is created when you start consuming from the topic.

Output:
[source,json]
----
{
"topic": "tutorial",
"value": "hello",
"timestamp": 1734640650348,
"partition": 0,
"offset": 0
}
{
"topic": "tutorial",
"value": "world",
"timestamp": 1734640653558,
"partition": 0,
"offset": 1
}
----

See xref:reference:rpk/rpk-topic/rpk-topic-consume.adoc[].

== List all consumer groups

List available consumer groups in your cluster:

[source,bash]
----
rpk group list
----

Output:
[source,bash]
----
BROKER GROUP STATE
0 tutorial-group Empty
----

See xref:reference:rpk/rpk-group/rpk-group-list.adoc[].

== Get a description of a consumer group

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

[source,bash]
----
rpk group describe tutorial-group
----
Output:
[source,bash]
----
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
----

See xref:reference:rpk/rpk-group/rpk-group-describe.adoc[].

== Delete a consumer group

Clean up by removing the `tutorial-group` consumer group:

[source,bash]
----
rpk group delete tutorial-group
----
Output:
[source,bash]
----
GROUP STATUS
tutorial-group OK
----

See xref:reference:rpk/rpk-group/rpk-group-delete.adoc[].

== Delete a topic

Clean up by removing the `tutorial` topic:

[source,bash]
----
rpk topic delete tutorial
----
Output:
[source,bash]
----
TOPIC STATUS
tutorial OK
----

See xref:reference:rpk/rpk-topic/rpk-topic-delete.adoc[].

== Next steps

* To generate a profile to save and reuse configurations for different Redpanda clusters, see xref:get-started:config-rpk-profile.adoc#about-rpk-profiles[About rpk profiles].
* For the complete list of `rpk` commands and their syntax, see the xref:reference:rpk/index.adoc[rpk Command Reference].

// end::single-source[]