Aug 15, 2022
7 min read

Introducing Pulsar Resources Operator for Kubernetes

Eric Shen
Product Manager, StreamNative
Fushu Wang
Cloud Engineer, StreamNative

We are excited to announce the release of Pulsar Resources Operator as an open-source project under the Apache License V2. The Pulsar Resources Operator provides declarative management of key Pulsar resources on Kubernetes.

What is the Pulsar Resources Operator?

The Pulsar Resources Operator is an independent controller that automatically manages Pulsar resources on Kubernetes using manifest files. The Pulsar Resources Operator provides full lifecycle management for the following Pulsar resources, including creation, update, and deletion:

Why do you need the Pulsar Resources Operator?

While you can manage Pulsar resources with CLI tools such as pulsar-admin and pulsarctl, or a client SDK, these are not the best practice when you are running a Pulsar cluster on Kubernetes. It’s very easy and useful to create a Pulsar resource by applying its manifest files, especially if you want to initialize some basic Pulsar resources in your CI workflow when creating a new Pulsar cluster.

Get started with the Pulsar Resources Operator

You can install the Pulsar Resources Operator using the officially supported pulsar-resources-operator Helm chart. It provides Custom Resource Definitions (CRDs) and Controllers to manage Pulsar resources.

Prerequisites

  • Install kubectl (v1.16 - v1.24), compatible with your cluster (+/- 1 minor release from your cluster).
  • Install Helm (v3.0.2 or higher).
  • Prepare a Kubernetes cluster (v1.16 - v1.24).
  • Prepare a Pulsar cluster.

Steps

To install the Pulsar Resources Operator, perform the following steps.

  1. Add the StreamNative chart repository.
helm repo add streamnative https://charts.streamnative.io
helm repo update

2. Install the operator using the pulsar-resources-operator Helm chart.

helm install <release-name> streamnative/pulsar-resources-operator -n <k8s-namespace> --create-namespace
kubectl get pods -n <k8s-namespace>
  1. When you want to upgrade the operator, use the following commands. You need to pull the chart file, decompress the tgz file, and then apply the crds.
helm repo update
helm pull streamnative/pulsar-resources-operator
tar -zxvf pulsar-resources-operator-v0.1.0.tgz
kubectl apply -f pulsar-resources-operator/crds
helm upgrade <release-name> streamnative/pulsar-resources-operator -n <k8s-namespace>

For more details about the installation, see the Installation section on GitHub.

Create the PulsarConnection

The PulsarConnection covers the address of the Pulsar cluster and the authentication information. The Operator uses it to access the Pulsar cluster to create other resources.

To create the PulsarConnection:

  1. Define a connection named pulsar-connection that contains the fields shown in the file below.
apiVersion: pulsar.streamnative.io/v1alpha1
kind: PulsarConnection
metadata:
  name: pulsar-connection
  namespace: <k8s-namespace>
spec:
  adminServiceURL: http://pulsar-sn-platform-broker.test.svc.cluster.local:8080
  1. Apply the YAML file to create the PulsarConnection and check the status.
kubectl  apply -f connection.yaml

kubectl get pulsarconnections -n <k8s-namespace>
NAME              ADMIN_SERVICE_URL   GENERATION   OBSERVED_GENERATION   READY
pulsar-connection   http://pulsar-xxxx:8080 1            1                True

Create Pulsar resources

The Pulsar Resources Operator allows you to quickly create Pulsar resources (for example, PulsarTenant and PulsarNamespace) on Kubernetes using YAML files. The following example demonstrates how to create a PulsarTenant object on Kubernetes.

  1. Create a YAML file named pulsar-tenant that contains the fields shown below.
apiVersion: pulsar.streamnative.io/v1alpha1
kind: PulsarTenant
metadata:
  name: pulsar-tenant
  namespace: <k8s-namespace>
spec:
  name: pulsar-tenant
  connectionRef:
    name: pulsar-connection
  adminRoles:
  - admin
  - ops

2. Apply the YAML file to create the tenant and check the status.

kubectl apply -f tenant.yaml

kubectl get pulsartenants -n <k8s-namespace>
NAME              RESOURCE_NAME   GENERATION   OBSERVED_GENERATION   READY
pulsar-tenant      pulsar-tenant      1                1               True

More resources

Check out the following resources to learn more about the Pulsar Resources Operator.

Eric Shen
Eric Shen is a Product Manager at StreamNative. He previously worked at Microsoft & Qiniu & PingCAP & Hikvision and focused on Cloud, Storage, and Databases.
Fushu Wang
Fushu Wang is a Cloud Engineer at StreamNative.

Newsletter

Our strategies and tactics delivered right to your inbox

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Apache Pulsar Announcements