- StreamNative Platform
- Connect
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 about 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
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.
Generate the App credentials by following the similar instructions in the configure OAuth2 authentication user guide.
Save the App credentials into an OAuth2 credential file.
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 calleddemo
based on the App registration details.pulsarctl context set demo \ --issuer-endpoint "your-issuer-url" \ --audience "your-audience" \ --client-id "pulsarctl_app_client_id"
issuer-endpoint
: the URL of your OAuth2 identity provider.audience
: theaudience
of your Pulsar cluster.client-id
: the client ID of thepulsarctl
CLI tool.
Log in to your Pulsar cluster.
pulsarctl oauth2 active \ --key-file "file:///path/to/private-key-file.json" \ --issuer-endpoint "your-issuer-url" \ --audience "your-audience" \ --scope "your-scope"
key-file
: the path to your OAuth2 credential file.issuer-endpoint
: the URL of your OAuth2 identity provider.audience
: theaudience
of your Pulsar cluster.scope
: the JWT claim that is used as the scope claims.
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 | +-------------+