Work with organizations
An organization is a team account configured perfectly for your use case on the cloud provider of your choice. Currently, snctl does not support creating organizations. You can create an organization through StreamNative Cloud Console. For details about how to create an organization, see create an organization. After you have created an organization through StreamNative Cloud Console, you can use thesnctl config set --organization command to set your default organization.
With the
organization option, you need to use the random string for the organization name, not the descriptive name. You can find the random string on the Dashboard, next to the organization’s descriptive name. For an example, see organizations.Work with instances
In this section, we named the organization
matrix for an example.Create an instance
A Pulsar instance is a group of clusters that acts together as a single unit. To create an instance through snctl, follow these steps.-
Define an instance named
neoby using a manifest file and save the manifest fileinstance-neo.yaml.-
This example shows how to create an instance on Google Cloud.
-
This example shows how to create an instance on AWS.
-
This example shows how to create an instance on Google Cloud.
-
Apply the manifest file to create the instance.
-
Check whether the instance is created successfully. This example shows whether the instance is successfully created on AWS.
OutputFrom the outputs, you can see that the
statusandtypeparameters for items underConditionsare set totrueandready. This means that the instanceneois created successfully.
snctl create pulsarinstance PULSAR_INSTANCE_NAME command to create an instance. For details, see snctl reference.
Check the instance
You can use the following command to list all created instances.Check instance details
Before checking details about an instance, you should use the following command to confirm whether the target instance is available.neo.
Delete an instance
You can use the following command to delete a specific instance based on the instance name.Work with clusters
A cluster is a secure messaging environment within Pulsar. Each Pulsar cluster consists a set of 3 components in a geographical location.- Pulsar brokers - set of brokers handling all the data going in and out of Pulsar (or client requests)
- Metadata storage - providing coordination and service discovery between services
- Bookie ensemble - set of bookies that retain copies of the messages
In StreamNative Console, you can create one and only one cluster for an instance.
matrix.
Create a cluster
Before you can create a cluster through
snctl, you need to create a billing subscription. For more information, see subscribe to StreamNative Cloud.-
Define a cluster named
neo-1by using a manifest file and save the manifest fileclusterneo1.yaml.The following table lists fields in the manifest file.
-
Apply the manifest file to create the cluster.
-
Check whether the cluster is created successfully.
Output
Check the cluster
You can use the following command to list all created clusters.Check cluster details
Before checking the details about a cluster, you should use the following command to confirm whether the target cluster is available.neo-1.
Interact with Clusters using Service Context
Starting fromsnctl version v1.0.0, the Service Context feature provides a streamlined way to interact directly with your Pulsar clusters (using both Pulsar and Kafka protocols) without needing to manually specify connection details for every command.
A Service Context stores the necessary service URL and authentication information for connecting to a specific cluster. snctl typically automatically discovers your StreamNative Cloud Pulsar clusters after you log in (snctl auth login) and makes them available as contexts.
1. Viewing and Switching Contexts
You usually don’t need to manually create contexts for your cloud clusters. To see which context is currently active and switch between available contexts:
-
Check the current active context:
Output (Example)
-
Switch to a different context (e.g., your cluster named
neo-1):Output (Example)Now, all subsequentpulsarandkafkacommands will target theneo-1cluster.
snctl context add-external-context, snctl context list-external-context, etc.)
2. Using pulsar and kafka Commands with the Active Context
Once a context is active, you can run pulsar and kafka commands directly:
-
Produce a message to a topic using the Pulsar protocol:
(Note: Replace
<organization_name>with your actual organization name if not set as default) -
List Pulsar tenants using the admin API:
-
Consume messages from a topic using the Kafka protocol (requires KoP enabled on the cluster):
-
List Kafka topics using the admin API (requires KoP):
snctl allows this using flags, and it will verify your user has permission to impersonate the specified service account.
-
Run a command using a named service account (
--as-service-account): -
Interactively choose a service account to run as (
--use-service-account): This will prompt you to select from service accounts your user is allowed to impersonate.
snctl, making it a more powerful and unified tool.
Add clusters to the Pulsar configuration file
This section describes how to add a cluster to the Pulsar client configuration file by defining acontext for that cluster. Then, you can access the cluster using the pulsarctl CLI tool.
-
Add a cluster to the Pulsar client configuration file.
This example adds a
neo-1cluster to the Pulsar client configuration file. InputOutput -
Verify that the current context has been changed.
Input
Output
pulsarctl CLI tool to interact with the target cluster. For details, see Connect to cluster through pulsarctl and perform other operations.
Delete a cluster
You cannot delete a cluster if there are resources associated with the cluster.
Work with service accounts
In this section, the organization has the name
matrix as an example name.Create a service account
To create a service account through snctl, follow these steps.-
Define a service account resource named
botby using a manifest file and save the manifest filesa-bot.yaml.The following table lists fields in the manifest file.
-
Apply the manifest file to create the service account.
Output
-
Check whether the service account was created successfully.
OutputFrom the output, you can see that the
statusandtypeparameters for items underConditionsare set totrueandready. This means that the service accountbotwas created successfully.
snctl create serviceaccount SERVICE_ACCOUNT_NAME command to create a service account. For details, see snctl reference.
Download service account credentials
To use a service account, you first download its associated credentials to a JSON file. The information is made available through thestatus block of the ServiceAccount resource.
The following example shows how to download the service account credentials to a file called bot.json.
The file contains credentials information and should be well protected.
Download service account tokens
To get a token using the StreamNative CLIsnctl, run the following command.
script
Activate a service account
This example shows how to activate a service account through a key file calledbot.json.
Access the StreamNative Cloud API
This example shows how to access the StreamNative Cloud API through a service account.-
Log in to snctl.
-
Create a service account.
This example creates a service account named bot.
Output
-
Download the associated credentials of the service account to a JSON file。
Output
-
Bind the service account with an “admin” role.
Output
-
Log out from snctl.
-
Log in to snctl with the service account.
Output
Check service accounts
This example shows how to check the service accounts of an organization.Check service account details
Before checking the details about a service account, you should use the following command to confirm whether the service account is available.bot.
Delete a service account
You can use the following command to delete a service account based on the service account name.Work with API Keys
To work with API keys using
snctl, you need to snctl version 0.16.0 or later.Create an API Key
To create an API key that doesn’t have an expiration date, do the following:View API Keys
To view API keys, use the following command:Revoke an API Key
To revoke an API key, use the following:Delete an API Key
To delete an API key, use the following:Work with users
In this document, we named the organization
matrix for an exampleCreate a user
To create a user, follow these steps.-
Define a user named
ironmanby using a manifest file and save the manifest fileuser-ironman.yaml.The following table lists fields in the manifest file.
| spec | Specify the email address for the user. |
-
Apply the manifest file to create the user.
-
Check whether the user is created successfully.
Output
Check users
You can use the following command to check users created for an organization.Check user details
Before checking details about a user, you should use the following command to confirm whether the target user is available.ironman@matrix.local.