Kubernetes quickstart with local access on minikube
This guide will help you set up Redpanda locally for development and testing purposes on macOS, Windows, or Linux. Start here if you want to set up Redpanda quickly to try it out or for CI/CD purposes. If you want to use Amazon EKS or GKE, see the Kubernetes quickstart for cloud. If you want to run Redpanda using kind with local access, see the Kubernetes quickstart with local access on kind.
This guide uses minikube to create a local Kubernetes cluster in which Redpanda is deployed. It also verifies that the Kafka API port is exposed to your local network so that you can interact with Redpanda from your local machine and not just from inside the Kubernetes cluster.
To get up and running, you'll create a cluster and deploy the Redpanda operator on the cluster. This guide will walk you through the steps to do that.
This quickstart guide walks you through the following steps:
- Create a Kubernetes cluster with minikube
- Install cert-manager
- Install the Redpanda operator
- Install and connect to a Redpanda cluster
- Start streaming
- Clean up
The steps in this guide limit the number of nodes to one because multi-node local clusters are not currently supported. For details on how to access Redpanda outside the Kubernetes network, see the Connecting remotely to Kubernetes guide.
In the steps below, the
.yaml file that you use to install Redpanda sets
developerMode: true. If you want to set
developerMode: false, for optimal configuration it is recommended that you run
rpk redpanda tune all directly on the host before you create a Redpanda cluster. You can find more information about the command as well as tuning recommendations in the Set Redpanda production mode documentation. If
rpk is not available, verify that
fs.aio-max-nr is set to
1048576 or greater. You can set
fs.aio-max-nr by running
sysctl -w fs.aio-max-nr=1048576.
Before you install Redpanda, verify that you have the following software installed on the machine where you want to run Redpanda:
kubectl version 1.21 or later
Helm version 3.0.0 or later
minikube version 1.25.1 or later
jq - This setup uses jq to set the Redpanda
$VERSIONenvironment variable. The steps below assume that you have jq installed, but if you don’t, you can run the same commands by replacing the
$VERSIONenvironment variable with the version of Redpanda that you’re using. Run the one of the commands below to install jq:
brew install jq
sudo apt-get update && \
sudo apt-get install jq
Step 1: Create a Kubernetes cluster with minikube
minikube start command to start up minikube and Kubernetes:
Verify that Kubernetes is running with this command:
Step 2: Install cert-manager
The Redpanda operator requires cert-manager to create certificates for TLS communication. You can install cert-manager with Helm or kubectl.
Before you install cert-manager, verify that the version you’re installing is compatible with your Kubernetes version. The cert-manager Supported Releases documentation lists which Kubernetes versions are supported.
Use this command to install cert-manager with Helm:
helm repo add jetstack https://charts.jetstack.io && \
helm repo update && \
helm install \
cert-manager jetstack/cert-manager \
--namespace cert-manager \
--version v1.7.0 \
Verify the cert-manager installation
Use the verification procedure in the cert-manager documentation to verify that cert-manager is deployed correctly.
Step 3: Use Helm to install the Redpanda operator
- Run the following command to use Helm to add the Redpanda chart repository and update it:
helm repo add redpanda https://charts.vectorized.io/ && \
helm repo update
- Use the following command to set the
$VERSIONenvironment variable to the latest operator and Redpanda version:
export VERSION=$(curl -s https://api.github.com/repos/redpanda-data/redpanda/releases/latest | jq -r .tag_name)
If you prefer to manually enter the Redpanda version, or if you want to verify the version, run this command to return the installed version:
curl -s https://api.github.com/repos/redpanda-data/redpanda/releases/latest | grep tag_name
You can find information about the versions of the operator in the list of operator releases.
Install the Redpanda operator CRD with the bash or zsh command below:
kubectl apply \
noglob kubectl apply \
Install the Redpanda operator on your Kubernetes cluster with this command:
helm install \
--namespace redpanda-system \
Step 4: Install and connect to a Redpanda cluster
After you set up Redpanda in your Kubernetes cluster, you can use the sample configuration files in GitHub to install a cluster and see Redpanda in action.
The example here is an imaginary chat application,
panda-chat, but you can replace
panda-chat with any string. In this example,
panda-chat has five chat rooms.
Complete the following steps to manage a stream of events from
- Create a namespace for the cluster with this command:
kubectl create ns panda-ns
- Install a single-node cluster like this (note that only single-node clusters are supported for local access clusters):
kubectl apply \
-n panda-ns \
You can view the resource configuration options, such as storage capacity, network configuration, or TLS configuration in the cluster_types file in GitHub. You can also find additional sample configuration files.
- Verify that the cluster was created successfully with this command:
kubectl exec -it -n panda-ns one-node-cluster-0 -- rpk cluster metadata --brokers='localhost:9092'
Step 5: Do some streaming
The Redpanda image contains the
redpanda binaries. Redpanda Keeper, or
rpk, is a CLI utility that you can use to work with your Redpanda nodes. See the rpk commands documentation for a full list of commands.
Follow these steps to start working with the
panda-ns cluster you created in the previous section.
- Create a
panda-chattopic with five partitions:
kubectl exec -it -n panda-ns one-node-cluster-0 -- rpk topic create panda-chat -p 5 --brokers='localhost:9092'
- Produce messages to the topic:
kubectl exec -it -n panda-ns one-node-cluster-0 -- rpk topic produce panda-chat --brokers='localhost:9092'
Type text into the topic, such as
Pandas are fabulous!.
- Press Enter to separate between messages.
- Press Ctrl + D to exit the produce command.
Consume (i.e. read) the messages in the topic with this command:
kubectl exec -it -n panda-ns one-node-cluster-0 -- rpk topic consume panda-chat --brokers='localhost:9092'
Each message is shown with its metadata, like this:
"message": "Pandas are fabulous!\n",
- List the topics:
kubectl exec -it -n panda-ns one-node-cluster-0 -- rpk topic list --brokers='localhost:9092'
Step 6: Clean up
Now that you’ve completed the quickstart, you can delete your cluster with the following command:
See the minikube
delete documentation for more information.