At Redpanda, operational simplicity and a good developer experience (DX) are two of our major goals. rpk
was born because of that: you shouldn't need to be a Linux expert to configure the machine where Redpanda will run. You shouldn't need magic shell scripts to do basic stuff such as querying a topic's health. We've been there, and we know it sucks.
We also think you shouldn't need to follow long guides to get started (and yes, we're working to make our onboarding guide even shorter and simpler!). A single command should do the trick.
Introducing: rpk container
Today I'm very happy to introduce rpk container
, a group of rpk
commands that will allow developers to deploy local multi-node Redpanda clusters in an instant! rpk container
uses the official Redpanda image to spin up a local containerized cluster.
The best thing, though, is that this feature is also available for Mac users!
If you haven't done so yet, follow the installation instructions for Linux or MacOS so you can follow along.
rpk container
leverages Docker. If you haven't done so already, please follow the installation instructions for Docker (Linux users) or Docker Desktop for Mac (MacOS users).
It's important to note, however, that you won't need to interact with Docker directly or have experience with it.
To get started, run rpk container start -n 3
. This will start a 3-node cluster. You should see something like this (the addresses may vary):
Note:rpk container start
will take a minute the first time you run it, since it will download the latest stable version of Redpanda. The next time you run it it should be quicker.
$ rpk container start -n 3
Starting cluster
Waiting for the cluster to be ready...
NODE ID ADDRESS
0 127.0.0.1:65279
1 127.0.0.1:65287
2 127.0.0.1:65286
Cluster started! You may use rpk to interact with it. E.g:
rpk cluster info
It says we can check our cluster with rpk cluster info
. Let's try that!
When you run rpk
commands, you need to include the list of brokers to run the command against. In our example that would be:
$ rpk cluster info --brokers 127.0.0.1:65279,127.0.0.1:65287,127.0.0.1:65286
BROKERS
=======
ID HOST PORT
0* 127.0.0.1 65279
1 127.0.0.1 65287
2 127.0.0.1 65286
For example, you can run rpk topic create
and it will work!
$ rpk topic create -p 6 -r 3 new-topic --brokers 127.0.0.1:65279,127.0.0.1:65287,127.0.0.1:65286
Created topic 'new-topic'. Partitions: 6, replicas: 3, cleanup policy: 'delete'
Now verify that the topic was created with rpk topic list
:
$ rpk topic list --brokers 127.0.0.1:65279,127.0.0.1:65287,127.0.0.1:65286
Name Partitions Replicas
new-topic 6 3
Check our previous blog post on getting started with Redpanda to learn more about rpk topic
.
To stop a cluster, run rpk container stop
:
$ rpk container stop
Stopping node 2
Stopping node 0
Stopping node 1
And you can restart it by running rpk container start
again.
$ rpk container start
Waiting for the cluster to be ready...
Found an existing cluster:
NODE ID ADDRESS
2 127.0.0.1:43551
0 127.0.0.1:37893
1 127.0.0.1:46027
To change the number of nodes, first purge the existing cluster:
rpk container purge
Finally, if you wanna wipe out all the cluster data and configuration, you can use rpk container purge
.
$ rpk container purge
Stopping node 0
Stopping node 2
Stopping node 1
Deleted cluster data.
It's worth also mentioning that Redpanda's API is Kafka®-compatible, so you can point your existing code or Kafka® client to the local cluster's addresses and keep hacking. You don't need to change your existing code, deploy Zookeeper, craft complex docker-compose files or maintain obscure bash scripts.
Announcing the official vectorized/redpanda
Docker image
The ideal way to run a database such as Redpanda is as a "standalone" process. You can achieve that by deploying each Redpanda broker on a different machine, and using the systemd units included in our pre-built packages for Debian and RHEL systems to achieve as much isolation as possible (i.e. by running sudo systemctl start redpanda
). This also guarantees you will get the best results out of rpk redpanda tune
.
However, we know that's not always possible. In a world where Docker & Kubernetes have become the standard, we need to provide the tools for you to be able to get the best out of Redpanda, no matter how you choose to deploy it.
So thanks to everyone in our Community Slack workspace who shared their interest in running Redpanda in a container; Roko, our Head of Solutions Engineering who gathered all the feedback; and Dimitris, who has been hard at work to enable the continuous release of new Redpanda Docker Images, I'm glad to say there's now an official vectorized/redpanda
Docker image that you can try today.
This is the image used by rpk container
behind the curtains, so if you followed the brief guide above, you already have it. If you don't, you can pull it by running docker pull vectorized/redpanda
.
It works out of the box, so if you wanna start a single broker you can run docker run -ti -p 9092:9092 vectorized/redpanda
and start using it right away. However, for dev environments rpk container start
is the recommended way.
We hope rpk container
and our official Docker image will help you deploy Redpanda more easily both locally and to production, and that they will help you be more productive and focus on writing code that matters.
If you have any feedback regarding this post, rpk
, or Redpanda, or if you just wanna chat, join us on Slack!
Let's keep in touch
Subscribe and never miss another blog post, announcement, or community event. We hate spam and will never sell your contact information.