pulsar-admin namespaces: Tenants and Namespaces
pulsar-admin namespaces create <tenant>/<namespace> creates a Pulsar namespace, the container that topics live in, before you create those topics.
Pulsar groups topics under tenant/namespace. Tests that use a custom namespace must create it (and often set retention) before creating topics under it.
What it does
pulsar-admin namespaces manages namespaces. create makes a namespace under a tenant; list shows namespaces in a tenant; set-retention controls how long messages without an active subscription are kept. A standalone broker ships the public/default namespace out of the box.
Common usage
pulsar-admin namespaces create public/test
pulsar-admin namespaces list public
# keep messages for 1 hour / up to 1 GB with no active subscriber
pulsar-admin namespaces set-retention public/test \
--time 1h --size 1GOptions
| Command / flag | What it does |
|---|---|
| namespaces create <tenant>/<ns> | Create a namespace |
| namespaces list <tenant> | List namespaces in a tenant |
| namespaces set-retention <ns> --time <t> --size <s> | Set retention limits |
| namespaces policies <ns> | Show the namespace policies |
| --admin-url <url> | Override the admin service URL |
In CI
By default retention is zero, so a message with no subscriber is deleted immediately; if a test produces before the consumer subscribes, set-retention so the message survives. Create the tenant first if it is not public, since namespaces live under a tenant.
Common errors in CI
"Tenant does not exist" means create the tenant (pulsar-admin tenants create) before the namespace. "Namespace already exists" (HTTP 409) is harmless on a retried job. "Connection refused" to :8080 means the broker admin API is not ready; standalone Pulsar needs a few seconds to boot.