Blog
7 min read

Introducing Pulsar Resources Operator for Kubernetes

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.
<script>
helm repo add streamnative https://charts.streamnative.io
helm repo update
<script> 

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

<script>
helm install  streamnative/pulsar-resources-operator -n  --create-namespace
kubectl get pods -n 
<script> 
  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.
<script>
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  streamnative/pulsar-resources-operator -n 
<script> 

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.
<script>
apiVersion: pulsar.streamnative.io/v1alpha1
kind: PulsarConnection
metadata:
  name: pulsar-connection
  namespace: 
spec:
  adminServiceURL: http://pulsar-sn-platform-broker.test.svc.cluster.local:8080
<script> 
  1. Apply the YAML file to create the PulsarConnection and check the status.
<script>
kubectl  apply -f connection.yaml

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

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.
<script>
apiVersion: pulsar.streamnative.io/v1alpha1
kind: PulsarTenant
metadata:
  name: pulsar-tenant
  namespace: 
spec:
  name: pulsar-tenant
  connectionRef:
    name: pulsar-connection
  adminRoles:
  - admin
  - ops
<script> 

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

<script>
kubectl apply -f tenant.yaml

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

More resources

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

Eric Shen
Eric Shen is the Solution Engineer of StreamNative. He previously worked at Microsoft & Qiniu & PingCAP & Hikvision mainly focusing on Cloud, Storage, Database. He is quietly interested in open source software and distributed systems.
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.