Skip to content

Sync Pulsar namespace and topic policies

Keep each policy where it is set.

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.

What you get if you do not ask for the risky part:

$ kurkik pulsar sync a.yaml b --configs --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.
Nothing to change.
left alone (8)
differs persistent://shop/orders/created retention.time --overwrite
differs persistent://shop/orders/created retention.size --overwrite
differs shop/orders backlog-quota destination_storage --overwrite
differs shop/orders message-ttl --overwrite
differs shop/orders retention --overwrite
differs shop/orders schema-compatibility-strategy --overwrite
differs persistent://shop/orders/paid deduplication --overwrite
and 1 difference sync does not act on - servers, messages, undeclared settings; kurkik pulsar diff shows them
0 changes - 7 still differ
exit 2

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

$ kurkik pulsar sync a.yaml b --configs --overwrite --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 (7)
~ set shop/orders backlog-quota destination_storage (not set) -> limit 536870912 bytes, producer_request_hold
~ set shop/orders message-ttl 7200 -> 3600 [destroys messages]
Every topic of shop/orders that sets no message-ttl of its own gets 3600: what falls outside it is acknowledged on every subscription.
~ set shop/orders schema-compatibility-strategy (not set) -> BACKWARD
~ set shop/orders retention (not set) -> timeInMinutes=60, sizeInMB=1024
~ set persistent://shop/orders/created retention.time (not set) -> 120
~ set persistent://shop/orders/created retention.size (not set) -> 20480
~ unset persistent://shop/orders/paid deduplication true -> (inherited)
note: Pulsar settles topic policies asynchronously: kurkik reads back for up to 30s before calling a change unconfirmed.
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 (1)
and 1 difference sync does not act on - servers, messages, undeclared settings; kurkik pulsar diff shows them
applying needs: tenant admin on shop
7 changes, 1 destroy
Apache Pulsar has no rehearsal: the plan above is all of it. Nothing was changed.
exit 2
$ kurkik pulsar sync a.yaml b --configs --overwrite --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 (7)
~ set shop/orders backlog-quota destination_storage (not set) -> limit 536870912 bytes, producer_request_hold
~ set shop/orders message-ttl 7200 -> 3600 [destroys messages]
Every topic of shop/orders that sets no message-ttl of its own gets 3600: what falls outside it is acknowledged on every subscription.
~ set shop/orders schema-compatibility-strategy (not set) -> BACKWARD
~ set shop/orders retention (not set) -> timeInMinutes=60, sizeInMB=1024
~ set persistent://shop/orders/created retention.time (not set) -> 120
~ set persistent://shop/orders/created retention.size (not set) -> 20480
~ unset persistent://shop/orders/paid deduplication true -> (inherited)
note: Pulsar settles topic policies asynchronously: kurkik reads back for up to 30s before calling a change unconfirmed.
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 (1)
and 1 difference sync does not act on - servers, messages, undeclared settings; kurkik pulsar diff shows them
applying needs: tenant admin on shop
7 changes, 1 destroy
applied
[+] done set shop/orders backlog-quota destination_storage (not set) -> limit 536870912 bytes, producer_request_hold
[+] done set shop/orders message-ttl 7200 -> 3600
[+] done set shop/orders schema-compatibility-strategy (not set) -> BACKWARD
[+] done set shop/orders retention (not set) -> timeInMinutes=60, sizeInMB=1024
[+] done set persistent://shop/orders/created retention.time (not set) -> 120
[+] done set persistent://shop/orders/created retention.size (not set) -> 20480
[+] done unset persistent://shop/orders/paid deduplication true -> (inherited)
Applied 7 of 7 changes - 1 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 0

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: "set-setting:shop/orders:backlog-quota destination_storage"
undo: "REMOVE_SETTING_OVERRIDE"
target: "shop/orders"
field: "backlog-quota destination_storage"
preState:
override: false
note: "The system had no setting of its own here, so undoing means removing one."
definition:
scope: "NAMESPACE"
- forAction: "set-setting:shop/orders:message-ttl"
undo: "SET_SETTING"
target: "shop/orders"
field: "message-ttl"
preState:
value: "7200"
override: true
definition:
scope: "NAMESPACE"
- forAction: "set-setting:shop/orders:schema-compatibility-strategy"
undo: "REMOVE_SETTING_OVERRIDE"
target: "shop/orders"
field: "schema-compatibility-strategy"
preState:
override: false
note: "The system had no setting of its own here, so undoing means removing one."
definition:
scope: "NAMESPACE"
- forAction: "set-setting:shop/orders:retention"
undo: "REMOVE_SETTING_OVERRIDE"
target: "shop/orders"
field: "retention"
preState:
override: false
note: "The system had no setting of its own here, so undoing means removing one."
definition:
scope: "NAMESPACE"
- forAction: "set-setting:persistent://shop/orders/created:retention.time"
undo: "REMOVE_SETTING_OVERRIDE"
target: "persistent://shop/orders/created"
field: "retention.time"
preState:
override: false
note: "The system had no setting of its own here, so undoing means removing one."
- forAction: "set-setting:persistent://shop/orders/created:retention.size"
undo: "REMOVE_SETTING_OVERRIDE"
target: "persistent://shop/orders/created"
field: "retention.size"
preState:
override: false
note: "The system had no setting of its own here, so undoing means removing one."
- forAction: "remove-setting:persistent://shop/orders/paid:deduplication"
undo: "SET_SETTING"
target: "persistent://shop/orders/paid"
field: "deduplication"
preState:
value: "true"
override: true

Download rollback.yaml

$ kurkik pulsar diff a.yaml b --configs
a.yaml vs b
Notes
- Broker settings that name a machine or a cluster were not compared: advertisedAddress, clusterName, metadataStoreUrl, statusFilePath.
- Not compared: ACLs, consumers, schemas, functions, connectors. Add --acls --consumers --schemas --functions --connectors, or --all, to compare them.
Drift: 0 changed · 0 unmanaged · 0 missing (no drift) - 46 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 (7)
~ set persistent://shop/orders/paid deduplication (not set) -> true
~ unset persistent://shop/orders/created retention.size 20480 -> (not set) [destroys messages]
The namespace's value is in force again, and it may be the lower one.
~ unset persistent://shop/orders/created retention.time 120 -> (not set) [destroys messages]
The namespace's value is in force again, and it may be the lower one.
~ unset shop/orders retention timeInMinutes=60, sizeInMB=1024 -> (not set)
~ unset shop/orders schema-compatibility-strategy BACKWARD -> (not set)
~ set shop/orders message-ttl 3600 -> 7200
~ unset shop/orders backlog-quota destination_storage limit 536870912 bytes, producer_request_hold -> (not set)
note: Pulsar settles topic policies asynchronously: kurkik reads back for up to 30s before calling a change unconfirmed.
note: A namespace's policies reach every topic in it that sets none of its own, including topics the document does not describe.
applying needs: tenant admin on shop
7 changes, 2 destroy
applied
[+] done set persistent://shop/orders/paid deduplication (not set) -> true
[+] done unset persistent://shop/orders/created retention.size 20480 -> (not set)
[+] done unset persistent://shop/orders/created retention.time 120 -> (not set)
[+] done unset shop/orders retention timeInMinutes=60, sizeInMB=1024 -> (not set)
[+] done unset shop/orders schema-compatibility-strategy BACKWARD -> (not set)
[+] done set shop/orders message-ttl 3600 -> 7200
[+] done unset shop/orders backlog-quota destination_storage limit 536870912 bytes, producer_request_hold -> (not set)
Applied 7 of 7 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) - 44 matched

source.yaml, 196 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:
backlog-quota destination_storage: "limit 536870912 bytes, producer_request_hold"
message-ttl: 3600
retention:
timeInMinutes: 60
sizeInMB: 1024
schema-autoupdate: "on"
schema-compatibility-strategy: BACKWARD
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
retention:
time: 120
size: 20480
ttl: 3600
x-kurkik:
pulsar:
channel:
topic: persistent://shop/orders/created
tenant: shop
namespace: orders
persistence: persistent
partitions: 0
geo-replication:
- standalone
retention:
time: 120
size: 20480
ttl: 3600
topicConfiguration:
backlog-quota destination_storage: "limit 536870912 bytes, producer_request_hold"
message-ttl: 3600
partitions: 0
persistence: persistent
replication-clusters:
- standalone
retention:
timeInMinutes: 120
sizeInMB: 20480
schema-autoupdate: "on"
schema-compatibility-strategy: BACKWARD
setOnTopic:
- retention
persistent-shop-orders-paid:
address: persistent://shop/orders/paid
bindings:
pulsar:
bindingVersion: 0.1.0
namespace: orders
persistence: persistent
retention:
time: 60
size: 1024
ttl: 3600
x-kurkik:
pulsar:
channel:
topic: persistent://shop/orders/paid
tenant: shop
namespace: orders
persistence: persistent
partitions: 2
geo-replication:
- standalone
retention:
time: 60
size: 1024
ttl: 3600
topicConfiguration:
backlog-quota destination_storage: "limit 536870912 bytes, producer_request_hold"
message-ttl: 3600
partitions: 2
persistence: persistent
replication-clusters:
- standalone
retention:
timeInMinutes: 60
sizeInMB: 1024
schema-autoupdate: "on"
schema-compatibility-strategy: BACKWARD
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, 172 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
tenant: shop
x-kurkik:
pulsar:
server:
cluster: standalone
brokers:
- localhost:8080
schemaRegistryUrl: http://pulsar-b:8080
schemaRegistryVendor: pulsar
namespacePolicies:
public/default:
schema-autoupdate: "on"
shop/orders:
message-ttl: 7200
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-b:6650
webServiceUrl: http://pulsar-b:8080
producerConfiguration: {}
consumerConfiguration: {}
channels:
persistent-shop-orders-created:
address: persistent://shop/orders/created
bindings:
pulsar:
bindingVersion: 0.1.0
namespace: orders
persistence: persistent
ttl: 7200
x-kurkik:
pulsar:
channel:
topic: persistent://shop/orders/created
tenant: shop
namespace: orders
persistence: persistent
partitions: 0
geo-replication:
- standalone
ttl: 7200
topicConfiguration:
message-ttl: 7200
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
ttl: 7200
deduplication: true
x-kurkik:
pulsar:
channel:
topic: persistent://shop/orders/paid
tenant: shop
namespace: orders
persistence: persistent
partitions: 2
deduplication: true
geo-replication:
- standalone
ttl: 7200
topicConfiguration:
deduplication: true
message-ttl: 7200
partitions: 2
persistence: persistent
replication-clusters:
- standalone
schema-autoupdate: "on"
setOnTopic:
- deduplication
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 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-admin --admin-url http://pulsar-a:8080 namespaces set-backlog-quota shop/orders --limit 512M --policy producer_request_hold --type destination_storage
pulsar-admin --admin-url http://pulsar-a:8080 namespaces set-retention shop/orders --time 60m --size 1024M
pulsar-admin --admin-url http://pulsar-a:8080 namespaces set-message-ttl shop/orders --messageTTL 3600
pulsar-admin --admin-url http://pulsar-a:8080 topicPolicies set-retention persistent://shop/orders/created --time 120m --size 20480M
pulsar-admin --admin-url http://pulsar-a:8080 namespaces set-schema-compatibility-strategy shop/orders --compatibility BACKWARD

Pulsar b

Terminal window
pulsar-admin --admin-url http://pulsar-b:8080 tenants create shop --allowed-clusters standalone --admin-roles shop-admin
pulsar-admin --admin-url http://pulsar-b:8080 namespaces create shop/orders --clusters standalone
pulsar-admin --admin-url http://pulsar-b:8080 topics create persistent://shop/orders/created
pulsar-admin --admin-url http://pulsar-b:8080 topics create-partitioned-topic persistent://shop/orders/paid --partitions 2
pulsar-admin --admin-url http://pulsar-b:8080 namespaces set-message-ttl shop/orders --messageTTL 7200
pulsar-admin --admin-url http://pulsar-b:8080 topicPolicies set-deduplication persistent://shop/orders/paid --enable

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 --configs --dry-run # plan-without.txt
kurkik pulsar sync a.yaml b --configs --overwrite --dry-run # plan.txt (and -o json: plan.json)
kurkik pulsar sync a.yaml b --configs --overwrite --yes # apply.txt, and the reverse patch: rollback.yaml
kurkik pulsar diff a.yaml b --configs # 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-admin --admin-url http://pulsar-a:8080 namespaces set-backlog-quota shop/orders --limit 512M --policy producer_request_hold --type destination_storage
pulsar-admin --admin-url http://pulsar-a:8080 namespaces set-retention shop/orders --time 60m --size 1024M
pulsar-admin --admin-url http://pulsar-a:8080 namespaces set-message-ttl shop/orders --messageTTL 3600
pulsar-admin --admin-url http://pulsar-a:8080 topicPolicies set-retention persistent://shop/orders/created --time 120m --size 20480M
pulsar-admin --admin-url http://pulsar-a:8080 namespaces set-schema-compatibility-strategy shop/orders --compatibility BACKWARD

Pulsar b

Terminal window
pulsar-admin --admin-url http://pulsar-b:8080 tenants create shop --allowed-clusters standalone --admin-roles shop-admin
pulsar-admin --admin-url http://pulsar-b:8080 namespaces create shop/orders --clusters standalone
pulsar-admin --admin-url http://pulsar-b:8080 topics create persistent://shop/orders/created
pulsar-admin --admin-url http://pulsar-b:8080 topics create-partitioned-topic persistent://shop/orders/paid --partitions 2
pulsar-admin --admin-url http://pulsar-b:8080 namespaces set-message-ttl shop/orders --messageTTL 7200
pulsar-admin --admin-url http://pulsar-b:8080 topicPolicies set-deduplication persistent://shop/orders/paid --enable

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 --configs --dry-run # plan-without.txt
kurkik pulsar sync a.yaml b --configs --overwrite --dry-run # plan.txt (and -o json: plan.json)
kurkik pulsar sync a.yaml b --configs --overwrite --yes # apply.txt, and the reverse patch: rollback.yaml
kurkik pulsar diff a.yaml b --configs # 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 --configs --overwrite --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 (8)
~ set standalone dispatchThrottlingRatePerTopicInMsg 2000 -> 1000
A dynamic setting: every broker of the cluster takes it at once, and keeps it over a restart (it is stored in the metadata store).
~ set shop/orders backlog-quota destination_storage (not set) -> limit 536870912 bytes, producer_request_hold
~ set shop/orders message-ttl 7200 -> 3600 [destroys messages]
Every topic of shop/orders that sets no message-ttl of its own gets 3600: what falls outside it is acknowledged on every subscription.
~ set shop/orders schema-compatibility-strategy (not set) -> BACKWARD
~ set shop/orders retention (not set) -> timeInMinutes=60, sizeInMB=1024
~ set persistent://shop/orders/created retention.time (not set) -> 120
~ set persistent://shop/orders/created retention.size (not set) -> 20480
~ unset persistent://shop/orders/paid deduplication true -> (inherited)
note: Pulsar settles topic policies asynchronously: kurkik reads back for up to 30s before calling a change unconfirmed.
note: A namespace's policies reach every topic in it that sets none of its own, including topics the document does not describe.
note: A dynamic broker setting applies to every broker of the cluster at once; settings read from broker.conf are listed, never changed.
left alone (2)
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.
and 1 difference sync does not act on - servers, messages, undeclared settings; kurkik pulsar diff shows them
applying needs: tenant admin on shop; a superuser, to change the brokers' dynamic settings
8 changes, 1 destroy - 1 still differs
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-admin --admin-url http://pulsar-a:8080 namespaces set-backlog-quota shop/orders --limit 512M --policy producer_request_hold --type destination_storage
pulsar-admin --admin-url http://pulsar-a:8080 namespaces set-retention shop/orders --time 60m --size 1024M
pulsar-admin --admin-url http://pulsar-a:8080 namespaces set-message-ttl shop/orders --messageTTL 3600
pulsar-admin --admin-url http://pulsar-a:8080 topicPolicies set-retention persistent://shop/orders/created --time 120m --size 20480M
pulsar-admin --admin-url http://pulsar-a:8080 namespaces set-schema-compatibility-strategy shop/orders --compatibility BACKWARD

Pulsar b

Terminal window
pulsar-admin --admin-url http://pulsar-b:8080 tenants create shop --allowed-clusters standalone --admin-roles shop-admin
pulsar-admin --admin-url http://pulsar-b:8080 namespaces create shop/orders --clusters standalone
pulsar-admin --admin-url http://pulsar-b:8080 topics create persistent://shop/orders/created
pulsar-admin --admin-url http://pulsar-b:8080 topics create-partitioned-topic persistent://shop/orders/paid --partitions 2
pulsar-admin --admin-url http://pulsar-b:8080 namespaces set-message-ttl shop/orders --messageTTL 7200
pulsar-admin --admin-url http://pulsar-b:8080 topicPolicies set-deduplication persistent://shop/orders/paid --enable

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 --configs --dry-run # plan-without.txt
kurkik pulsar sync a.yaml b --configs --overwrite --dry-run # plan.txt (and -o json: plan.json)
kurkik pulsar sync a.yaml b --configs --overwrite --yes # apply.txt, and the reverse patch: rollback.yaml
kurkik pulsar diff a.yaml b --configs # 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