Skip to content

Commit 9328ffa

Browse files
DeflaimunmicheleRPr-vasquez
authored
DOC-31 add rpk tutorial (#935)
Co-authored-by: Michele Cyran <michele@redpanda.com> Co-authored-by: Rogger Vasquez <59714880+r-vasquez@users.noreply.github.com>
1 parent 4ea8ab4 commit 9328ffa

File tree

4 files changed

+256
-2
lines changed

4 files changed

+256
-2
lines changed

modules/ROOT/nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
** xref:get-started:quickstarts.adoc[Quickstarts]
99
*** xref:get-started:quick-start.adoc[Redpanda Self-Managed]
1010
*** xref:console:quickstart.adoc[Redpanda Console]
11+
*** xref:get-started:rpk-quickstart.adoc[]
1112
*** xref:get-started:docker-compose-labs.adoc[Docker Compose Labs]
1213
** xref:get-started:licensing/index.adoc[Redpanda Licensing]
1314
*** xref:get-started:licensing/overview.adoc[Editions and Enterprise Features]

modules/get-started/pages/intro-to-rpk.adoc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ After you install `rpk`, you can use it to:
1111
* Set up access control lists (ACLs) and other security features
1212
* Create topics, produce to topics, and consume from topics
1313
14-
See also: xref:get-started:rpk-install.adoc[]
14+
See also:
15+
* xref:get-started:rpk-install.adoc[]
16+
* xref:get-started:config-rpk-profile.adoc[]
17+
* xref:get-started:rpk-quickstart.adoc[]
1518

1619
== Specify command properties
1720

modules/get-started/pages/rpk-install.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ include::get-started:partial$install-rpk-macos.adoc[]
3535

3636
== Next steps
3737

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

4041
// end::single-source[]
Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
= Redpanda CLI Quickstart
2+
:page-categories: rpk
3+
: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.]
4+
// Do not put page aliases in the single-sourced content
5+
// tag::single-source[]
6+
7+
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.
8+
9+
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].
10+
11+
== Pre-requisites
12+
13+
* A running Redpanda cluster.
14+
* The `rpk` CLI installed. See xref:get-started:rpk-install.adoc[].
15+
16+
== Create a topic
17+
18+
To start streaming data, first create a topic as the destination for your records:
19+
20+
[source,bash]
21+
----
22+
rpk topic create tutorial
23+
----
24+
25+
Output:
26+
[source,bash]
27+
----
28+
TOPIC STATUS
29+
tutorial OK
30+
----
31+
32+
See xref:reference:rpk/rpk-topic/rpk-topic-create.adoc[].
33+
34+
== Produce records to a topic
35+
36+
Produce records to the topic. Downstream consumers will then be able to read these records. To exit the producer session, press `Ctrl+C`:
37+
38+
[source,bash]
39+
----
40+
rpk topic produce tutorial
41+
----
42+
43+
Additional input:
44+
[source,bash]
45+
----
46+
hello
47+
world
48+
----
49+
50+
Output:
51+
[source,bash]
52+
----
53+
Produced to partition 0 at offset 0 with timestamp 1734640650348.
54+
Produced to partition 0 at offset 1 with timestamp 1734640653558.
55+
----
56+
57+
See xref:reference:rpk/rpk-topic/rpk-topic-produce.adoc[].
58+
59+
== Get a description of a topic
60+
61+
Check the topic’s configuration and status to ensure that it’s ready for use:
62+
63+
[source,bash]
64+
----
65+
rpk topic describe tutorial
66+
----
67+
68+
Output:
69+
[source,bash]
70+
----
71+
SUMMARY
72+
=======
73+
NAME tutorial
74+
PARTITIONS 1
75+
REPLICAS 1
76+
77+
CONFIGS
78+
=======
79+
KEY VALUE SOURCE
80+
cleanup.policy delete DEFAULT_CONFIG
81+
compression.type producer DEFAULT_CONFIG
82+
delete.retention.ms -1 DEFAULT_CONFIG
83+
flush.bytes 262144 DEFAULT_CONFIG
84+
flush.ms 100 DEFAULT_CONFIG
85+
initial.retention.local.target.bytes -1 DEFAULT_CONFIG
86+
initial.retention.local.target.ms -1 DEFAULT_CONFIG
87+
max.message.bytes 1048576 DEFAULT_CONFIG
88+
message.timestamp.type CreateTime DEFAULT_CONFIG
89+
redpanda.iceberg.delete true DEFAULT_CONFIG
90+
redpanda.iceberg.mode disabled DEFAULT_CONFIG
91+
redpanda.leaders.preference none DEFAULT_CONFIG
92+
redpanda.remote.delete true DEFAULT_CONFIG
93+
redpanda.remote.read false DEFAULT_CONFIG
94+
redpanda.remote.write false DEFAULT_CONFIG
95+
retention.bytes -1 DEFAULT_CONFIG
96+
retention.local.target.bytes -1 DEFAULT_CONFIG
97+
retention.local.target.ms 86400000 DEFAULT_CONFIG
98+
retention.ms 604800000 DEFAULT_CONFIG
99+
segment.bytes 134217728 DEFAULT_CONFIG
100+
segment.ms 1209600000 DEFAULT_CONFIG
101+
write.caching true DEFAULT_CONFIG
102+
----
103+
104+
See xref:reference:rpk/rpk-topic/rpk-topic-describe.adoc[].
105+
106+
== Consume records from a topic
107+
108+
Consume records from the topic:
109+
110+
[source,bash]
111+
----
112+
rpk topic consume tutorial
113+
----
114+
115+
Output:
116+
[source,json]
117+
----
118+
{ "topic": "tutorial", "value": "hello", "timestamp": 1678807229837, "partition": 0, "offset": 0 }
119+
{ "topic": "tutorial", "value": "world", "timestamp": 1678807232413, "partition": 0, "offset": 1 }
120+
----
121+
122+
Consume from an offset, where `2` is not inclusive:
123+
[source,bash]
124+
----
125+
rpk topic consume tutorial --offset 0:2
126+
----
127+
Output:
128+
[source,json]
129+
----
130+
{ "topic": "tutorial", "value": "hello", "timestamp": 1678807229837, "partition": 0, "offset": 0 }
131+
{ "topic": "tutorial", "value": "world", "timestamp": 1678807232413, "partition": 0, "offset": 1 }
132+
----
133+
134+
See xref:reference:rpk/rpk-topic/rpk-topic-consume.adoc[].
135+
136+
== Create a consumer group and consume topics
137+
138+
Organize consumers into groups to share workloads and balance consumption:
139+
140+
[source,bash]
141+
----
142+
rpk topic consume tutorial --group tutorial-group
143+
----
144+
145+
NOTE: The consumer group is created when you start consuming from the topic.
146+
147+
Output:
148+
[source,json]
149+
----
150+
{
151+
"topic": "tutorial",
152+
"value": "hello",
153+
"timestamp": 1734640650348,
154+
"partition": 0,
155+
"offset": 0
156+
}
157+
{
158+
"topic": "tutorial",
159+
"value": "world",
160+
"timestamp": 1734640653558,
161+
"partition": 0,
162+
"offset": 1
163+
}
164+
----
165+
166+
See xref:reference:rpk/rpk-topic/rpk-topic-consume.adoc[].
167+
168+
== List all consumer groups
169+
170+
List available consumer groups in your cluster:
171+
172+
[source,bash]
173+
----
174+
rpk group list
175+
----
176+
177+
Output:
178+
[source,bash]
179+
----
180+
BROKER GROUP STATE
181+
0 tutorial-group Empty
182+
----
183+
184+
See xref:reference:rpk/rpk-group/rpk-group-list.adoc[].
185+
186+
== Get a description of a consumer group
187+
188+
View details about the consumer group’s state, coordinator, members, and offsets:
189+
190+
[source,bash]
191+
----
192+
rpk group describe tutorial-group
193+
----
194+
Output:
195+
[source,bash]
196+
----
197+
GROUP tutorial-group
198+
COORDINATOR 0
199+
STATE Empty
200+
BALANCER
201+
MEMBERS 0
202+
TOTAL-LAG 0
203+
204+
TOPIC PARTITION CURRENT-OFFSET LOG-START-OFFSET LOG-END-OFFSET LAG MEMBER-ID CLIENT-ID HOST
205+
tutorial 0 2 0 2 0
206+
----
207+
208+
See xref:reference:rpk/rpk-group/rpk-group-describe.adoc[].
209+
210+
== Delete a consumer group
211+
212+
Clean up by removing the `tutorial-group` consumer group:
213+
214+
[source,bash]
215+
----
216+
rpk group delete tutorial-group
217+
----
218+
Output:
219+
[source,bash]
220+
----
221+
GROUP STATUS
222+
tutorial-group OK
223+
----
224+
225+
See xref:reference:rpk/rpk-group/rpk-group-delete.adoc[].
226+
227+
== Delete a topic
228+
229+
Clean up by removing the `tutorial` topic:
230+
231+
[source,bash]
232+
----
233+
rpk topic delete tutorial
234+
----
235+
Output:
236+
[source,bash]
237+
----
238+
TOPIC STATUS
239+
tutorial OK
240+
----
241+
242+
See xref:reference:rpk/rpk-topic/rpk-topic-delete.adoc[].
243+
244+
== Next steps
245+
246+
* 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].
247+
* For the complete list of `rpk` commands and their syntax, see the xref:reference:rpk/index.adoc[rpk Command Reference].
248+
249+
// end::single-source[]

0 commit comments

Comments
 (0)