Getting Started with Kubernetes

Published: February 22, 2022

This guide is for getting started using the Pulsar on Kubernetes.

Prerequisites

Pulsar is developed in 64-bit Java. To run the binaries you need either the Java Runtime Environment(JRE) or Java Developer Kit(JDK) version 8 or later installed. Installers and more info available here.

With a Java environment in place, all popular 64-bit desktops are supported - Windows, Linux, and MacOS.

Steps

Start the Pulsar broker

Pulsar has quite a few supporting services (Bookkeeper, Zookeeper, etc). Within the main binary there is a standalone command that will run everything needed. Learn more about the command here.

1
2
3
4
kubectl apply -f https:https://www.pulsar-neighborhood.iomanifests/standalone-k8s.yaml

# Start a port forward
kubectl -n pulsar port-forward service/pulsar-broker 6650:6650

Get the Pulsar binaries

Pulsar is developed for 64-bit Java. To run the binaries you need either the Java Runtime Environment(JRE) or Java Developer Kit(JDK) version 8 or later installed. Installers and more info available here.

With a Java environment in place, all popular 64-bit desktops are supported - Windows, Linux, and MacOS. The tarball is around 300mb, so please be patient while downloading.

Send a message to the Broker

Otherwise known as producing a message. Pulsar will create a new topic (if it doesn’t already exist) named “my-first-topic”.

1
./bin/pulsar-client --url "pulsar://localhost:6650/default/public/" produce "my-first-topic" --messages "Hello there"

There will be quite a bit of feedback output to the screen. Upon a successful publish, the last line should be…

[main] INFO org.apache.pulsar.client.cli.PulsarClientTool - 1 messages successfully produced

Get messages from the Broker

Otherwise known as consuming messages. Similar to producing, if the topic does not exists Pulsar will create it.

1
./bin/pulsar-client --url "pulsar://localhost:6650/default/public/" consume "my-first-topic" -s "my-subscription"

There will be quite a bit of feedback output to the screen. Upon a successful connection, the last line should be…

[main] INFO org.apache.pulsar.client.cli.PulsarClientTool - 1 messages successfully consumed

Stop the Broker

1
kubectl delete -f https:https://www.pulsar-neighborhood.iomanifests/standalone-k8s.yaml

Summary

Troubleshooting

Error: JAVA_HOME not set, and no java executable found in…

The JAVA_HOME environment variable is a way of interacting with the runtime. Usually when this value is not set, that indicates there is no Java environment installed. Refer to the prerequisites.

Popup window: How do you want to open this file?

This is a popup that appears in Windows when you try to execute an unknown type of binary. Refer to the prerequisites to install the Java environment.