1. Tools
  2. pulsarctl

Connect to Pulsar cluster using pulsarctl CLI tool

pulsarctl is a CLI tool that you can use to manage Pulsar clusters. This document provides examples of how to use the pulsarctl CLI tool to connect to a Pulsar cluster through a token or an OAuth2 credential file.

Connect to a Pulsar cluster using a token

This example shows how to use the pulsarctl CLI tool to connect to your Pulsar cluster using a token and then list tenants available for this cluster.

pulsarctl \
  --admin-service-url "WEB_SERVICE_URL" \
  --token "AUTH_PARAMS" \
  tenants list

Set the admin-service-url and token parameters based on the descriptions in the prepare to connect to a Pulsar cluster user guide.

Connect to a Pulsar cluster using an OAuth2 credential file

Note

If it is the first time you install and use the pulsarctl CLI tool, you must use the pulsarctl context set command to set a context (cluster) in advance.

To connect to your Pulsar cluster using an OAuth2 credential file, follow these steps.

  1. Generate the App credentials by following similar instructions in the configure OAuth2 authentication user guide.

  2. Save the App credentials into an OAuth2 credential file.

  3. Create a context.

    The pulsarctl CLI tool uses a configuration file for cluster-specific settings. Each cluster is associated with a context. This example creates a context called neo-1 based on the App registration details.

    pulsarctl context set "neo-1" \
     --admin-service-url "${adminServiceURL}" \
     --issuer-endpoint "${domain}" \
     --audience "urn:sn:pulsar:${orgName}:${instanceName}" \
     --key-file "file://YOUR-KEY-FILE-PATH"
    
    • admin-service-url: the service URL of your Pulsar cluster.
    • issuer-endpoint: the URL of your OAuth2 identity provider.
    • audience: the audience of your Pulsar cluster.
    • key-file: the absolute path to your OAuth2 credential file.
  4. Log in to your Pulsar cluster.

    pulsarctl oauth2 activate
    
  5. Get Pulsar resources.

    This example lists tenants for the cluster neo-1.

    Input

    pulsarctl tenants list --cluster-name <neo-1>
    

    OutPut

    +-------------+
    | TENANT NAME |
    +-------------+
    | public      |
    | pulsar      |
    | sn          |
    +-------------+
    
Previous
Configuration Reference