- StreamNative Cloud
- Connect
Connect to cluster through pulsar-admin
The pulsar-admin tool enables you to manage Pulsar components, including clusters, brokers, namespaces, tenants, and more. pulsar-admin uses the conf/client.conf config file in a Pulsar installation. This document describes how to connect to a cluster through the pulsar-admin CLI tool, and use the producer and consumer to produce and consume messages to and from a topic.
This document assumes that you have created a Pulsar cluster and a service account, and have granted the service account produce
and consume
permissions to the namespace for the target topic.
Prerequisites
- Pulsar client 2.6.1 or higher version
Connect to cluster through OAuth2 authentication plugin
To connect a cluster through the OAuth2 authentication plugin, follow these steps.
Get the Pulsar Web service URL. For details, see get a service URL.
Get the OAuth2 credential file of your service account. For details, see get an OAuth2 credential file.
Connect to a Pulsar cluster through the OAuth2 authentication plugin.
bin/pulsar-admin --admin-url https://streamnative.cloud:443 \ --auth-plugin org.apache.pulsar.client.impl.auth.oauth2.AuthenticationOAuth2 \ --auth-params '{"privateKey":"file:///absolute path/to/key/file.json", "issuerUrl":"https://auth.streamnative.cloud", "audience":"urn:sn:pulsar:test-pulsar-instance-namespace:test-pulsar-instance"}' \ tenants list
admin-url
: the HTTP service URL of your Pulsar cluster.privateKey
: the path to your downloaded OAuth2 credential file. TheprivateKey
parameter supports the following three pattern formats:file:///path/to/file
file:/path/to/file
data:application/json;base64,<base64-encoded value>
issuerUrl
: the URL of your OAuth2 authentication provider. You can get the value from your downloaded OAuth2 credential file.audience
: theaudience
parameter is the Uniform Resource Name (URN), which is a combination of theurn:sn:pulsar
, the organization name, and the Pulsar instance name, in this formaturn:sn:pulsar:<org_name>:<instance_name>
.
Connect to cluster through Token authentication plugin
To connect a cluster through the Token authentication plugin, follow these steps.
Get the Pulsar Web service URL. For details, see get a service URL.
Get the token of your service account. For details, see get a token.
Connect to a Pulsar cluster through the Token authentication plugin.
./bin/pulsar-admin \ --admin-url WEB_SERVICE_URL \ --auth-params AUTH_PARAMS \ tenants list
admin-url
: the HTTP service URL of your Pulsar cluster.auth-params
: the token of your service account.
For details about how to use pulsar-admin to manage Pulsar components, see pulsar-admin command reference.