Skip to content

Create Pulsar topics on an empty cluster from AsyncAPI

The target has nothing. What does a plain sync make?

Terminal recording of kurkik pulsar sync

The recording shows kurkik pulsar sync on the demo sandbox; its data differs from this example.

Shown here: one cluster. Other broker setups are further down.

Nothing changes yet. --dry-run only shows what would happen.

$ kurkik pulsar sync a.yaml b --dry-run
Sync a.yaml into b - Apache Pulsar, cluster b (http://pulsar-b:8080)
owns: namespaces shop/orders - the ones its channels live in; permissions, as x-kurkik.pulsar.server.acl declares them
plan: <digest>
Run one sync per cluster at a time: two at once each plan against a state the other is changing.
changes (6)
+ create shop
+ create shop/orders
~ set tenant shop adminRoles (not set) -> shop-admin
Tenant shop is administered by shop-admin: a role it no longer names loses admin of every namespace in it.
~ set shop/orders schema-autoupdate (not set) -> on
+ create persistent://shop/orders/created
+ create persistent://shop/orders/paid
note: Pulsar settles topic policies asynchronously: kurkik reads back for up to 30s before calling a change unconfirmed.
note: Pulsar enforces permissions only on a broker with authorization enabled; one without stores them and checks nothing.
note: A namespace's policies reach every topic in it that sets none of its own, including topics the document does not describe.
left alone (4)
not decided standalone subscriptions
The comparison could not decide this, so sync leaves it alone. Subscriptions could not be compared: on b, subscriptions were not asked for (--consumers).
not decided standalone producers
The comparison could not decide this, so sync leaves it alone. Producers could not be compared: on b, producers were not asked for (--consumers).
and 2 differences sync does not act on - servers, messages, undeclared settings; kurkik pulsar diff shows them
applying needs: a superuser, to create tenant shop
6 changes - INCOMPLETE: something could not be decided
Apache Pulsar has no rehearsal: the plan above is all of it. Nothing was changed.
exit 2
$ kurkik pulsar sync a.yaml b --yes
Sync a.yaml into b - Apache Pulsar, cluster b (http://pulsar-b:8080)
owns: namespaces shop/orders - the ones its channels live in; permissions, as x-kurkik.pulsar.server.acl declares them
plan: <digest>
Run one sync per cluster at a time: two at once each plan against a state the other is changing.
changes (6)
+ create shop
+ create shop/orders
~ set tenant shop adminRoles (not set) -> shop-admin
Tenant shop is administered by shop-admin: a role it no longer names loses admin of every namespace in it.
~ set shop/orders schema-autoupdate (not set) -> on
+ create persistent://shop/orders/created
+ create persistent://shop/orders/paid
note: Pulsar settles topic policies asynchronously: kurkik reads back for up to 30s before calling a change unconfirmed.
note: Pulsar enforces permissions only on a broker with authorization enabled; one without stores them and checks nothing.
note: A namespace's policies reach every topic in it that sets none of its own, including topics the document does not describe.
left alone (4)
not decided standalone subscriptions
The comparison could not decide this, so sync leaves it alone. Subscriptions could not be compared: on b, subscriptions were not asked for (--consumers).
not decided standalone producers
The comparison could not decide this, so sync leaves it alone. Producers could not be compared: on b, producers were not asked for (--consumers).
and 2 differences sync does not act on - servers, messages, undeclared settings; kurkik pulsar diff shows them
applying needs: a superuser, to create tenant shop
6 changes - INCOMPLETE: something could not be decided
applied
[+] done create shop
[+] done create shop/orders
[+] done set tenant shop adminRoles (not set) -> shop-admin
[+] done set shop/orders schema-autoupdate (not set) -> on
[+] done create persistent://shop/orders/created
[+] done create persistent://shop/orders/paid
Applied 6 of 6 changes - 4 left alone
snapshot: ~/.local/state/kurkik/sync/b/b-<time>.snapshot.yaml
rollback: ~/.local/state/kurkik/sync/b/b-<time>.rollback.yaml
undo: kurkik pulsar sync revert ~/.local/state/kurkik/sync/b/b-<time>.snapshot.yaml
exit 3

Written before the first change.

rollback.yaml
system: "Apache Pulsar"
target: "b (http://pulsar-b:8080)"
createdAt: "<time>"
document: "~/.local/state/kurkik/sync/b/b-<time>.snapshot.yaml"
entries:
- forAction: "create-container:shop"
undo: "DELETE_CREATED_CONTAINER"
target: "shop"
note: "sync created this so a channel could live in it. A revert removes it while\
\ nothing else is in it."
- forAction: "create-container:shop/orders"
undo: "DELETE_CREATED_CONTAINER"
target: "shop/orders"
note: "sync created this so a channel could live in it. A revert removes it while\
\ nothing else is in it."
- forAction: "set-setting:tenant shop:adminRoles"
undo: "SET_SETTING"
target: "tenant shop"
field: "adminRoles"
preState:
value: "(none)"
override: true
- forAction: "set-setting:shop/orders:schema-autoupdate"
undo: "REMOVE_SETTING_OVERRIDE"
target: "shop/orders"
field: "schema-autoupdate"
preState:
override: false
note: "The system had no setting of its own here, so undoing means removing one."
definition:
scope: "NAMESPACE"
- forAction: "create-channel:persistent://shop/orders/created"
undo: "DELETE_CREATED_CHANNEL"
target: "persistent://shop/orders/created"
note: "sync created this. Undoing it deletes the channel and whatever was written\
\ to it since."
- forAction: "create-channel:persistent://shop/orders/paid"
undo: "DELETE_CREATED_CHANNEL"
target: "persistent://shop/orders/paid"
note: "sync created this. Undoing it deletes the channel and whatever was written\
\ to it since."

Download rollback.yaml

$ kurkik pulsar diff a.yaml b
a.yaml vs b
Notes
- Broker settings that name a machine or a cluster were not compared: advertisedAddress, clusterName, metadataStoreUrl, statusFilePath.
- Not compared: schemas. Add --schemas, or --all, to compare them.
Drift: 0 changed · 0 unmanaged · 0 missing (no drift) - 40 matched
exit 0
$ kurkik pulsar sync revert ~/.local/state/kurkik/sync/b/b-<time>.snapshot.yaml b --force --yes
Revert b to b-<time>.snapshot.yaml - Apache Pulsar, cluster b (http://pulsar-b:8080)
owns: what the run being undone changed, as its rollback records it
plan: <digest>
Run one sync per cluster at a time: two at once each plan against a state the other is changing.
changes (4)
- delete persistent://shop/orders/paid [destroys messages]
Every message written to persistent://shop/orders/paid since sync created it is deleted, and every subscription on it.
- delete persistent://shop/orders/created [destroys messages]
Every message written to persistent://shop/orders/created since sync created it is deleted, and every subscription on it.
- delete shop/orders shop/orders -> (not set) [deletes the tenant or namespace]
Deletes namespace shop/orders, which sync created: its policies and grants go with it. Nothing else is in it once the revert has removed what sync made.
- delete shop shop -> (not set) [deletes the tenant or namespace]
Deletes tenant shop, which sync created: its admin roles and allowed clusters go with it. Nothing else is in it once the revert has removed what sync made.
applying needs: tenant admin on shop
4 changes, 4 destroy
applied
[+] done delete persistent://shop/orders/paid
[+] done delete persistent://shop/orders/created
[+] done delete shop/orders shop/orders -> (not set)
[+] done delete shop shop -> (not set)
Applied 4 of 4 changes
snapshot: ~/.local/state/kurkik/sync/b/b-<time>.snapshot.yaml
rollback: ~/.local/state/kurkik/sync/b/b-<time>.rollback.yaml
undo: kurkik pulsar sync revert ~/.local/state/kurkik/sync/b/b-<time>.snapshot.yaml
exit 0

After the revert, compared with how it was before: Drift: 0 changed · 0 unmanaged · 0 missing (no drift) - 25 matched · 2 unknown - INCOMPLETE: some facts could not be checked

source.yaml, 160 lines
asyncapi: 3.0.0
info:
title: a Apache Pulsar API
version: 1.0.0-SNAPSHOT
description: Generated by reading Apache Pulsar of a (http://pulsar-a:8080).
servers:
standalone:
host: pulsar-a:6650
protocol: pulsar
protocolVersion: "4.0"
description: Apache Pulsar cluster standalone.
bindings:
pulsar:
bindingVersion: 0.1.0
tenant: shop
x-kurkik:
pulsar:
server:
cluster: standalone
brokers:
- localhost:8080
schemaRegistryUrl: http://pulsar-a:8080
schemaRegistryVendor: pulsar
namespacePolicies:
public/default:
schema-autoupdate: "on"
shop/orders:
schema-autoupdate: "on"
tenants:
- tenant: public
adminRoles: []
allowedClusters:
- standalone
- tenant: shop
adminRoles:
- shop-admin
allowedClusters:
- standalone
security:
- security: NONE
tls: false
acl: []
consumers: []
producers: []
functions: []
sources: []
sinks: []
brokerConfiguration:
advertisedAddress: localhost
backlogQuotaDefaultLimitGB: "10.0"
bookkeeperClientMinNumRacksPerWriteQuorum: "1"
bookkeeperClientReorderReadSequenceEnabled: "false"
bookkeeperNumberOfChannelsPerBookie: "1"
brokerDeleteInactiveTopicsEnabled: "false"
clusterName: standalone
enablePackagesManagement: "true"
forceDeleteNamespaceAllowed: "true"
functionsWorkerEnablePackageManagement: "true"
isRunningStandalone: "true"
loadBalancerEnabled: "false"
loadManagerClassName: org.apache.pulsar.broker.loadbalance.NoopLoadManager
managedLedgerCacheEvictionFrequency: "100.0"
managedLedgerDefaultAckQuorum: "1"
managedLedgerDefaultEnsembleSize: "1"
managedLedgerDefaultMarkDeleteRateLimit: "0.1"
managedLedgerDefaultWriteQuorum: "1"
metadataStoreUrl: rocksdb:///pulsar/data/metadata
packagesManagementStorageProvider: org.apache.pulsar.packages.management.storage.filesystem.FileSystemPackagesStorageProvider
statusFilePath: /usr/local/apache/htdocs
topicPublisherThrottlingTickTimeMillis: "2"
webSocketServiceEnabled: "true"
clientConfiguration:
serviceUrl: pulsar://pulsar-a:6650
webServiceUrl: http://pulsar-a:8080
producerConfiguration: {}
consumerConfiguration: {}
channels:
persistent-shop-orders-created:
address: persistent://shop/orders/created
bindings:
pulsar:
bindingVersion: 0.1.0
namespace: orders
persistence: persistent
x-kurkik:
pulsar:
channel:
topic: persistent://shop/orders/created
tenant: shop
namespace: orders
persistence: persistent
partitions: 0
geo-replication:
- standalone
topicConfiguration:
partitions: 0
persistence: persistent
replication-clusters:
- standalone
schema-autoupdate: "on"
persistent-shop-orders-paid:
address: persistent://shop/orders/paid
bindings:
pulsar:
bindingVersion: 0.1.0
namespace: orders
persistence: persistent
x-kurkik:
pulsar:
channel:
topic: persistent://shop/orders/paid
tenant: shop
namespace: orders
persistence: persistent
partitions: 2
geo-replication:
- standalone
topicConfiguration:
partitions: 2
persistence: persistent
replication-clusters:
- standalone
schema-autoupdate: "on"
operations:
receive_persistent-shop-orders-created:
action: receive
channel:
$ref: "#/channels/persistent-shop-orders-created"
x-kurkik:
pulsar:
operation:
security: []
consumerConfiguration: {}
receive_persistent-shop-orders-paid:
action: receive
channel:
$ref: "#/channels/persistent-shop-orders-paid"
x-kurkik:
pulsar:
operation:
security: []
consumerConfiguration: {}
send_persistent-shop-orders-created:
action: send
channel:
$ref: "#/channels/persistent-shop-orders-created"
x-kurkik:
pulsar:
operation:
security: []
producerConfiguration: {}
send_persistent-shop-orders-paid:
action: send
channel:
$ref: "#/channels/persistent-shop-orders-paid"
x-kurkik:
pulsar:
operation:
security: []
producerConfiguration: {}

Download source.yaml

target.yaml, 68 lines
asyncapi: 3.0.0
info:
title: b Apache Pulsar API
version: 1.0.0-SNAPSHOT
description: Generated by reading Apache Pulsar of b (http://pulsar-b:8080).
servers:
standalone:
host: pulsar-b:6650
protocol: pulsar
protocolVersion: "4.0"
description: Apache Pulsar cluster standalone.
bindings:
pulsar:
bindingVersion: 0.1.0
x-kurkik:
pulsar:
server:
cluster: standalone
brokers:
- localhost:8080
schemaRegistryUrl: http://pulsar-b:8080
schemaRegistryVendor: pulsar
namespacePolicies:
public/default:
schema-autoupdate: "on"
tenants:
- tenant: public
adminRoles: []
allowedClusters:
- standalone
security:
- security: NONE
tls: false
acl: []
functions: []
sources: []
sinks: []
brokerConfiguration:
advertisedAddress: localhost
backlogQuotaDefaultLimitGB: "10.0"
bookkeeperClientMinNumRacksPerWriteQuorum: "1"
bookkeeperClientReorderReadSequenceEnabled: "false"
bookkeeperNumberOfChannelsPerBookie: "1"
brokerDeleteInactiveTopicsEnabled: "false"
clusterName: standalone
enablePackagesManagement: "true"
forceDeleteNamespaceAllowed: "true"
functionsWorkerEnablePackageManagement: "true"
isRunningStandalone: "true"
loadBalancerEnabled: "false"
loadManagerClassName: org.apache.pulsar.broker.loadbalance.NoopLoadManager
managedLedgerCacheEvictionFrequency: "100.0"
managedLedgerDefaultAckQuorum: "1"
managedLedgerDefaultEnsembleSize: "1"
managedLedgerDefaultMarkDeleteRateLimit: "0.1"
managedLedgerDefaultWriteQuorum: "1"
metadataStoreUrl: rocksdb:///pulsar/data/metadata
packagesManagementStorageProvider: org.apache.pulsar.packages.management.storage.filesystem.FileSystemPackagesStorageProvider
statusFilePath: /usr/local/apache/htdocs
topicPublisherThrottlingTickTimeMillis: "2"
webSocketServiceEnabled: "true"
clientConfiguration:
serviceUrl: pulsar://pulsar-b:6650
webServiceUrl: http://pulsar-b:8080
producerConfiguration: {}
consumerConfiguration: {}
channels: {}
operations: {}

Download target.yaml

How to build this setup yourself

Clusters

Pulsar a

Terminal window
pulsar-admin --admin-url http://pulsar-a:8080 tenants create shop --allowed-clusters standalone --admin-roles shop-admin
pulsar-admin --admin-url http://pulsar-a:8080 namespaces create shop/orders --clusters standalone
pulsar-admin --admin-url http://pulsar-a:8080 topics create persistent://shop/orders/created
pulsar-admin --admin-url http://pulsar-a:8080 topics create-partitioned-topic persistent://shop/orders/paid --partitions 2

Pulsar b

Sync

Terminal window
kurkik conn add pulsar a --admin-url http://pulsar-a:8080 --service-url pulsar://pulsar-a:6650 --client 4.0
kurkik conn add pulsar b --admin-url http://pulsar-b:8080 --service-url pulsar://pulsar-b:6650 --client 4.0
kurkik pulsar export a --this-cluster-only --acls --consumers --stdout > a.yaml # source.yaml (and b's, before: target.yaml)
kurkik pulsar sync a.yaml b --dry-run # plan.txt (and -o json: plan.json)
kurkik pulsar sync a.yaml b --yes # apply.txt, and the reverse patch: rollback.yaml
kurkik pulsar diff a.yaml b # after.txt
kurkik pulsar sync revert ~/.local/state/kurkik/sync/b/b-<time>.snapshot.yaml b --force --yes # revert.txt

Same plan.

How to build this setup yourself

Clusters

Pulsar a

Terminal window
pulsar-admin --admin-url http://pulsar-a:8080 tenants create shop --allowed-clusters standalone --admin-roles shop-admin
pulsar-admin --admin-url http://pulsar-a:8080 namespaces create shop/orders --clusters standalone
pulsar-admin --admin-url http://pulsar-a:8080 topics create persistent://shop/orders/created
pulsar-admin --admin-url http://pulsar-a:8080 topics create-partitioned-topic persistent://shop/orders/paid --partitions 2

Pulsar b

Sync

Terminal window
kurkik conn add pulsar a --admin-url http://pulsar-a:8080 --service-url pulsar://pulsar-a:6650 --client 4.0
kurkik conn add pulsar b --admin-url http://pulsar-b:8080 --service-url pulsar://pulsar-b:6650 --client 4.0
kurkik pulsar export a --this-cluster-only --acls --consumers --stdout > a.yaml # source.yaml (and b's, before: target.yaml)
kurkik pulsar sync a.yaml b --dry-run # plan.txt (and -o json: plan.json)
kurkik pulsar sync a.yaml b --yes # apply.txt, and the reverse patch: rollback.yaml
kurkik pulsar diff a.yaml b # after.txt
kurkik pulsar sync revert ~/.local/state/kurkik/sync/b/b-<time>.snapshot.yaml b --force --yes # revert.txt
Show the plan
$ kurkik pulsar sync a.yaml b --dry-run
Sync a.yaml into b - Apache Pulsar, cluster b (http://pulsar-b:8080)
owns: namespaces shop/orders - the ones its channels live in; permissions, as x-kurkik.pulsar.server.acl declares them
plan: <digest>
Run one sync per cluster at a time: two at once each plan against a state the other is changing.
changes (6)
+ create shop
+ create shop/orders
~ set tenant shop adminRoles (not set) -> shop-admin
Tenant shop is administered by shop-admin: a role it no longer names loses admin of every namespace in it.
~ set shop/orders schema-autoupdate (not set) -> on
+ create persistent://shop/orders/created
+ create persistent://shop/orders/paid
note: Pulsar settles topic policies asynchronously: kurkik reads back for up to 30s before calling a change unconfirmed.
note: Pulsar enforces permissions only on a broker with authorization enabled; one without stores them and checks nothing.
note: A namespace's policies reach every topic in it that sets none of its own, including topics the document does not describe.
left alone (6)
differs standalone dispatchThrottlingRatePerTopicInMsg --overwrite
cannot change standalone maxConsumersPerSubscription
maxConsumersPerSubscription is not a dynamic broker setting on Pulsar 4.0: it is read from broker.conf when a broker starts. Set it to 50 in the broker.conf of every broker of the cluster and restart them; sync changes only what a broker takes at runtime.
not decided standalone subscriptions
The comparison could not decide this, so sync leaves it alone. Subscriptions could not be compared: on b, subscriptions were not asked for (--consumers).
not decided standalone producers
The comparison could not decide this, so sync leaves it alone. Producers could not be compared: on b, producers were not asked for (--consumers).
and 2 differences sync does not act on - servers, messages, undeclared settings; kurkik pulsar diff shows them
applying needs: a superuser, to create tenant shop
6 changes - 2 still differ - INCOMPLETE: something could not be decided
Apache Pulsar has no rehearsal: the plan above is all of it. Nothing was changed.
exit 2

Download

How to build this setup yourself

Clusters

Pulsar a

Terminal window
pulsar-admin --admin-url http://pulsar-a:8080 tenants create shop --allowed-clusters standalone --admin-roles shop-admin
pulsar-admin --admin-url http://pulsar-a:8080 namespaces create shop/orders --clusters standalone
pulsar-admin --admin-url http://pulsar-a:8080 topics create persistent://shop/orders/created
pulsar-admin --admin-url http://pulsar-a:8080 topics create-partitioned-topic persistent://shop/orders/paid --partitions 2

Pulsar b

Sync

Terminal window
kurkik conn add pulsar a --admin-url http://pulsar-a:8080 --service-url pulsar://pulsar-a:6650 --client 4.0
kurkik conn add pulsar b --admin-url http://pulsar-b:8080 --service-url pulsar://pulsar-b:6650 --client 4.0
kurkik pulsar export a --this-cluster-only --acls --consumers --stdout > a.yaml # source.yaml (and b's, before: target.yaml)
kurkik pulsar sync a.yaml b --dry-run # plan.txt (and -o json: plan.json)
kurkik pulsar sync a.yaml b --yes # apply.txt, and the reverse patch: rollback.yaml
kurkik pulsar diff a.yaml b # after.txt
kurkik pulsar sync revert ~/.local/state/kurkik/sync/b/b-<time>.snapshot.yaml b --force --yes # revert.txt

All flags: kurkik pulsar sync · more Apache Pulsar sync examples