Skip to content

Migrate a whole Pulsar namespace setup in one sync

Topics, policies, grants, subscriptions, schemas, functions: one plan.

Terminal recording of kurkik pulsar sync

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

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

$ kurkik pulsar sync a.yaml b --all --overwrite --revoke --delete --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 (10)
+ grant shop/orders billing (not set) -> consume
~ set shop/orders message-ttl (not set) -> 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.
+ create persistent://shop/orders/shipped
+ subscribe persistent://shop/orders/created subscription (not set) -> audit
+ register persistent://shop/orders/created schema (not set) -> STRING
1 version(s) of STRING, uploaded oldest first; Pulsar numbers them from 0.
+ register persistent://shop/orders/enriched schema (not set) -> STRING
1 version(s) of STRING, uploaded oldest first; Pulsar numbers them from 0.
+ register persistent://shop/orders/paid versions (not set) -> 2 version(s) [cannot be undone]
Appends the document's last 1 version(s) after the cluster's 1; the compatibility in force checks each. Pulsar deletes a topic's schema only whole, so undoing this replaces every version with the ones there were.
+ deploy function shop/orders/enrich function (not set) -> shop/orders/enrich
- delete persistent://shop/orders/ticks [destroys messages]
Every message in persistent://shop/orders/ticks is deleted, and every subscription on it with its position.
- unsubscribe persistent://shop/orders/paid [destroys messages]
legacy loses its position on persistent://shop/orders/paid: made again, it starts at the end.
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.
note: Pulsar checks each schema version against the compatibility in force, and deletes a topic's schema only whole: undoing an append re-uploads the versions there were.
note: A function, source or sink is deployed from the package or built-in connector the document names; its user configuration and secrets are not in a document, and are not set.
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; the functions permission on shop/orders (or tenant admin), and a function worker, to deploy or change what runs there
10 changes, 4 destroy
Apache Pulsar has no rehearsal: the plan above is all of it. Nothing was changed.
exit 2
$ kurkik pulsar sync a.yaml b --all --overwrite --revoke --delete --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 (10)
+ grant shop/orders billing (not set) -> consume
~ set shop/orders message-ttl (not set) -> 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.
+ create persistent://shop/orders/shipped
+ subscribe persistent://shop/orders/created subscription (not set) -> audit
+ register persistent://shop/orders/created schema (not set) -> STRING
1 version(s) of STRING, uploaded oldest first; Pulsar numbers them from 0.
+ register persistent://shop/orders/enriched schema (not set) -> STRING
1 version(s) of STRING, uploaded oldest first; Pulsar numbers them from 0.
+ register persistent://shop/orders/paid versions (not set) -> 2 version(s) [cannot be undone]
Appends the document's last 1 version(s) after the cluster's 1; the compatibility in force checks each. Pulsar deletes a topic's schema only whole, so undoing this replaces every version with the ones there were.
+ deploy function shop/orders/enrich function (not set) -> shop/orders/enrich
- delete persistent://shop/orders/ticks [destroys messages]
Every message in persistent://shop/orders/ticks is deleted, and every subscription on it with its position.
- unsubscribe persistent://shop/orders/paid [destroys messages]
legacy loses its position on persistent://shop/orders/paid: made again, it starts at the end.
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.
note: Pulsar checks each schema version against the compatibility in force, and deletes a topic's schema only whole: undoing an append re-uploads the versions there were.
note: A function, source or sink is deployed from the package or built-in connector the document names; its user configuration and secrets are not in a document, and are not set.
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; the functions permission on shop/orders (or tenant admin), and a function worker, to deploy or change what runs there
10 changes, 4 destroy
applied
[+] done grant shop/orders billing (not set) -> consume
[+] done set shop/orders message-ttl (not set) -> 3600
[+] done create persistent://shop/orders/shipped
[+] done subscribe persistent://shop/orders/created subscription (not set) -> audit
[+] done register persistent://shop/orders/created schema (not set) -> STRING
[+] done register persistent://shop/orders/enriched schema (not set) -> STRING
[+] done register persistent://shop/orders/paid versions (not set) -> 2 version(s)
[+] done deploy function shop/orders/enrich function (not set) -> shop/orders/enrich
[+] done delete persistent://shop/orders/ticks
[+] done unsubscribe persistent://shop/orders/paid
Applied 10 of 10 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: "grant-access:shop/orders:billing"
undo: "REVOKE_GRANTED_ACCESS"
target: "shop/orders"
field: "billing"
note: "sync granted this. Revoking it again cuts off whoever has started to rely\
\ on it."
definition:
actions: "consume"
role: "billing"
- forAction: "set-setting:shop/orders:message-ttl"
undo: "REMOVE_SETTING_OVERRIDE"
target: "shop/orders"
field: "message-ttl"
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/shipped"
undo: "DELETE_CREATED_CHANNEL"
target: "persistent://shop/orders/shipped"
note: "sync created this. Undoing it deletes the channel and whatever was written\
\ to it since."
- forAction: "create-subscription:persistent://shop/orders/created:subscription"
undo: "DELETE_CREATED_SUBSCRIPTION"
target: "persistent://shop/orders/created"
field: "subscription"
note: "sync created audit. Undoing it deletes it and its position."
definition:
subscription: "audit"
- forAction: "register-schema:persistent://shop/orders/created:schema"
undo: "DELETE_REGISTERED_SCHEMA"
target: "persistent://shop/orders/created"
field: "schema"
note: "sync registered this. Undoing it soft-deletes the version again."
definition:
expect: "[\"\"]"
type: "STRING"
versions: "[\"\"]"
- forAction: "register-schema:persistent://shop/orders/enriched:schema"
undo: "DELETE_REGISTERED_SCHEMA"
target: "persistent://shop/orders/enriched"
field: "schema"
note: "sync registered this. Undoing it soft-deletes the version again."
definition:
expect: "[\"\"]"
type: "STRING"
versions: "[\"\"]"
- forAction: "register-schema:persistent://shop/orders/paid:versions"
undo: "DELETE_REGISTERED_SCHEMA"
target: "persistent://shop/orders/paid"
field: "versions"
note: "sync registered this. Undoing it soft-deletes the version again."
definition:
before: "[\"{\\\"type\\\":\\\"record\\\",\\\"name\\\":\\\"Payment\\\",\\\"namespace\\\
\":\\\"shop\\\",\\\"fields\\\":[{\\\"name\\\":\\\"order\\\",\\\"type\\\":\\\"\
string\\\"},{\\\"name\\\":\\\"paid\\\",\\\"type\\\":\\\"boolean\\\"}]}\"]"
beforeType: "AVRO"
expect: "[\"{\\\"type\\\":\\\"record\\\",\\\"name\\\":\\\"Payment\\\",\\\"namespace\\\
\":\\\"shop\\\",\\\"fields\\\":[{\\\"name\\\":\\\"order\\\",\\\"type\\\":\\\"\
string\\\"},{\\\"name\\\":\\\"paid\\\",\\\"type\\\":\\\"boolean\\\"}]}\",\"\
{\\\"type\\\":\\\"record\\\",\\\"name\\\":\\\"Payment\\\",\\\"namespace\\\"\
:\\\"shop\\\",\\\"fields\\\":[{\\\"name\\\":\\\"order\\\",\\\"type\\\":\\\"\
string\\\"},{\\\"name\\\":\\\"paid\\\",\\\"type\\\":\\\"boolean\\\"},{\\\"name\\\
\":\\\"note\\\",\\\"type\\\":[\\\"null\\\",\\\"string\\\"],\\\"default\\\":null}]}\"\
]"
type: "AVRO"
versions: "[\"{\\\"type\\\":\\\"record\\\",\\\"name\\\":\\\"Payment\\\",\\\"namespace\\\
\":\\\"shop\\\",\\\"fields\\\":[{\\\"name\\\":\\\"order\\\",\\\"type\\\":\\\"\
string\\\"},{\\\"name\\\":\\\"paid\\\",\\\"type\\\":\\\"boolean\\\"},{\\\"name\\\
\":\\\"note\\\",\\\"type\\\":[\\\"null\\\",\\\"string\\\"],\\\"default\\\":null}]}\"\
]"
- forAction: "deploy-processor:function shop/orders/enrich:function"
undo: "DELETE_DEPLOYED_PROCESSOR"
target: "function shop/orders/enrich"
field: "function"
note: "sync deployed this. Undoing it stops and deletes it."
definition:
kind: "function"
name: "enrich"
namespace: "orders"
set.archive: "function://shop/orders/enrich@0"
set.className: "com.github.pakisan.kurkik.pulsar.fixtures.Enrich"
set.inputs: "persistent://shop/orders/created"
set.output: "persistent://shop/orders/enriched"
set.parallelism: "1"
set.processingGuarantees: "ATLEAST_ONCE"
set.runtime: "JAVA"
set.subscriptionName: "enrich"
tenant: "shop"
- forAction: "delete-channel:persistent://shop/orders/ticks"
undo: "RECREATE_DELETED_CHANNEL"
target: "persistent://shop/orders/ticks"
note: "sync deleted this. It can be made again as it was; its messages cannot."
definition:
partitions: "0"
persistent: "true"
- forAction: "delete-subscription:persistent://shop/orders/paid"
undo: "RECREATE_DELETED_SUBSCRIPTION"
target: "persistent://shop/orders/paid"
note: "sync deleted legacy. It can be made again; its position cannot."
definition:
subscription: "legacy"

Download rollback.yaml

$ kurkik pulsar diff a.yaml b --all
a.yaml vs b
ACLs
+ stale - b grants stale consume on topic persistent://shop/orders/paid; a.yaml does not.
Notes
- Broker settings that name a machine or a cluster were not compared: advertisedAddress, clusterName, metadataStoreUrl, statusFilePath.
Drift: 0 changed · 1 unmanaged · 0 missing (no drift) - 111 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 (10)
+ subscribe persistent://shop/orders/paid (not set) -> legacy
+ create persistent://shop/orders/ticks
- delete function shop/orders/enrich function [stops and deletes the processor]
function shop/orders/enrich stops: sync deployed it.
± replace persistent://shop/orders/paid versions [soft-deletes the subject's versions]
persistent://shop/orders/paid's schema is deleted and its 1 earlier version(s) uploaded again, numbered anew.
- soft-del persistent://shop/orders/enriched schema [soft-deletes schema versions]
Every version of persistent://shop/orders/enriched's schema is deleted, as before sync uploaded them.
- soft-del persistent://shop/orders/created schema [soft-deletes schema versions]
Every version of persistent://shop/orders/created's schema is deleted, as before sync uploaded them.
- unsubscribe persistent://shop/orders/created subscription audit -> (not set) [destroys messages]
audit loses its position on persistent://shop/orders/created.
read by enrich (1 connected)
- delete persistent://shop/orders/shipped [destroys messages]
Every message written to persistent://shop/orders/shipped since sync created it is deleted, and every subscription on it.
~ unset shop/orders message-ttl 3600 -> (not set)
- revoke shop/orders billing consume -> (not set) [revokes access]
billing loses what sync granted it on shop/orders; a client that has started relying on it fails.
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.
note: Pulsar checks each schema version against the compatibility in force, and deletes a topic's schema only whole: undoing an append re-uploads the versions there were.
note: A function, source or sink is deployed from the package or built-in connector the document names; its user configuration and secrets are not in a document, and are not set.
applying needs: tenant admin on shop; the functions permission on shop/orders (or tenant admin), and a function worker, to deploy or change what runs there
10 changes, 7 destroy
! 1 active subscriber on what this plan destroys (1 group, as of <time>):
persistent://shop/orders/created enrich (1 connected)
They lose their place, and the messages.
holding a position in persistent://shop/orders/created: audit - lost with it
applied
[+] done subscribe persistent://shop/orders/paid (not set) -> legacy
[+] done create persistent://shop/orders/ticks
[+] done delete function shop/orders/enrich function
[+] done replace persistent://shop/orders/paid versions
[+] done soft-del persistent://shop/orders/enriched schema
[+] done soft-del persistent://shop/orders/created schema
[+] done unsubscribe persistent://shop/orders/created subscription audit -> (not set)
[+] done delete persistent://shop/orders/shipped
[+] done unset shop/orders message-ttl 3600 -> (not set)
[+] done revoke shop/orders billing consume -> (not set)
Applied 10 of 10 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) - 80 matched

source.yaml, 485 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:
message-ttl: 3600
schema-autoupdate: "on"
tenants:
- tenant: public
adminRoles: []
allowedClusters:
- standalone
- tenant: shop
adminRoles:
- shop-admin
allowedClusters:
- standalone
security:
- security: NONE
tls: false
acl:
- role: billing
resourceType: namespace
name: shop/orders
actions:
- consume
consumers:
- subscription: audit
topics:
- persistent://shop/orders/created
consumers: []
- subscription: audit-log
type: Shared
topics:
- persistent://shop/orders/raw
processor: sink shop/orders/audit-log
- subscription: enrich
type: Shared
topics:
- persistent://shop/orders/created
processor: function shop/orders/enrich
producers: []
functions:
- tenant: shop
namespace: orders
name: enrich
runtime: JAVA
className: com.github.pakisan.kurkik.pulsar.fixtures.Enrich
archive: function://shop/orders/enrich@0
inputs:
- persistent://shop/orders/created
output: persistent://shop/orders/enriched
subscriptionName: enrich
parallelism: 1
processingGuarantees: ATLEAST_ONCE
channels:
- $ref: "#/channels/persistent-shop-orders-created"
- $ref: "#/channels/persistent-shop-orders-enriched"
roles: []
sources: []
sinks:
- tenant: shop
namespace: orders
name: audit-log
className: com.github.pakisan.kurkik.pulsar.fixtures.AuditLog
archive: sink://shop/orders/audit-log@0
inputs:
- persistent://shop/orders/raw
subscriptionName: audit-log
parallelism: 1
processingGuarantees: ATLEAST_ONCE
channels:
- $ref: "#/channels/persistent-shop-orders-raw"
roles: []
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
messages:
persistent-shop-orders-created:
payload:
type: string
name: persistent-shop-orders-created
title: persistent://shop/orders/created
summary: "Schema read from Pulsar's own registry: STRING, version 0."
x-kurkik:
pulsar:
message:
schemaType: STRING
schemaVersion: 0
schemaIdLocation: metadata
schemaLookupStrategy: topic
schemaCompatibility: FULL
key:
type: string
bindings:
pulsar:
bindingVersion: 0.1.0
namespace: orders
persistence: persistent
ttl: 3600
x-kurkik:
pulsar:
channel:
topic: persistent://shop/orders/created
tenant: shop
namespace: orders
persistence: persistent
partitions: 0
geo-replication:
- standalone
ttl: 3600
topicConfiguration:
message-ttl: 3600
partitions: 0
persistence: persistent
replication-clusters:
- standalone
schema-autoupdate: "on"
persistent-shop-orders-enriched:
address: persistent://shop/orders/enriched
messages:
persistent-shop-orders-enriched:
payload:
type: string
name: persistent-shop-orders-enriched
title: persistent://shop/orders/enriched
summary: "Schema read from Pulsar's own registry: STRING, version 0."
x-kurkik:
pulsar:
message:
schemaType: STRING
schemaVersion: 0
schemaIdLocation: metadata
schemaLookupStrategy: topic
schemaCompatibility: FULL
key:
type: string
bindings:
pulsar:
bindingVersion: 0.1.0
namespace: orders
persistence: persistent
ttl: 3600
x-kurkik:
pulsar:
channel:
topic: persistent://shop/orders/enriched
tenant: shop
namespace: orders
persistence: persistent
partitions: 0
geo-replication:
- standalone
ttl: 3600
topicConfiguration:
message-ttl: 3600
partitions: 0
persistence: persistent
replication-clusters:
- standalone
schema-autoupdate: "on"
persistent-shop-orders-paid:
address: persistent://shop/orders/paid
messages:
persistent-shop-orders-paid:
payload:
schemaFormat: application/vnd.apache.avro;version=1.9.0
schema:
type: record
name: Payment
namespace: shop
fields:
- name: order
type: string
- name: paid
type: boolean
- name: note
type:
- "null"
- string
default: null
name: persistent-shop-orders-paid
title: persistent://shop/orders/paid
summary: "Schema read from Pulsar's own registry: AVRO, version 1."
x-kurkik:
pulsar:
message:
schemaType: AVRO
schemaVersion: 1
schemaIdLocation: metadata
schemaLookupStrategy: topic
schemaCompatibility: FULL
schemaVersions:
- version: 0
schemaType: AVRO
schemaFormat: application/vnd.apache.avro;version=1.9.0
schema:
type: record
name: Payment
namespace: shop
fields:
- name: order
type: string
- name: paid
type: boolean
- version: 1
schemaType: AVRO
schemaFormat: application/vnd.apache.avro;version=1.9.0
schema:
type: record
name: Payment
namespace: shop
fields:
- name: order
type: string
- name: paid
type: boolean
- name: note
type:
- "null"
- string
default: null
key:
type: string
bindings:
pulsar:
bindingVersion: 0.1.0
namespace: orders
persistence: persistent
ttl: 3600
x-kurkik:
pulsar:
channel:
topic: persistent://shop/orders/paid
tenant: shop
namespace: orders
persistence: persistent
partitions: 2
geo-replication:
- standalone
ttl: 3600
topicConfiguration:
message-ttl: 3600
partitions: 2
persistence: persistent
replication-clusters:
- standalone
schema-autoupdate: "on"
persistent-shop-orders-raw:
address: persistent://shop/orders/raw
messages:
persistent-shop-orders-raw:
payload:
type: string
name: persistent-shop-orders-raw
title: persistent://shop/orders/raw
summary: "Schema read from Pulsar's own registry: STRING, version 0."
x-kurkik:
pulsar:
message:
schemaType: STRING
schemaVersion: 0
schemaIdLocation: metadata
schemaLookupStrategy: topic
schemaCompatibility: FULL
key:
type: string
bindings:
pulsar:
bindingVersion: 0.1.0
namespace: orders
persistence: persistent
ttl: 3600
x-kurkik:
pulsar:
channel:
topic: persistent://shop/orders/raw
tenant: shop
namespace: orders
persistence: persistent
partitions: 0
geo-replication:
- standalone
ttl: 3600
topicConfiguration:
message-ttl: 3600
partitions: 0
persistence: persistent
replication-clusters:
- standalone
schema-autoupdate: "on"
persistent-shop-orders-shipped:
address: persistent://shop/orders/shipped
bindings:
pulsar:
bindingVersion: 0.1.0
namespace: orders
persistence: persistent
ttl: 3600
x-kurkik:
pulsar:
channel:
topic: persistent://shop/orders/shipped
tenant: shop
namespace: orders
persistence: persistent
partitions: 0
geo-replication:
- standalone
ttl: 3600
topicConfiguration:
message-ttl: 3600
partitions: 0
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:
groupId:
type: string
enum:
- audit
- enrich
security:
- billing
processors:
- type: function
name: shop/orders/enrich
server: standalone
consumerConfiguration: {}
receive_persistent-shop-orders-enriched:
action: receive
channel:
$ref: "#/channels/persistent-shop-orders-enriched"
x-kurkik:
pulsar:
operation:
security:
- billing
consumerConfiguration: {}
receive_persistent-shop-orders-paid:
action: receive
channel:
$ref: "#/channels/persistent-shop-orders-paid"
x-kurkik:
pulsar:
operation:
security:
- billing
consumerConfiguration: {}
receive_persistent-shop-orders-raw:
action: receive
channel:
$ref: "#/channels/persistent-shop-orders-raw"
x-kurkik:
pulsar:
operation:
groupId:
type: string
enum:
- audit-log
security:
- billing
processors:
- type: sink
name: shop/orders/audit-log
server: standalone
consumerConfiguration: {}
receive_persistent-shop-orders-shipped:
action: receive
channel:
$ref: "#/channels/persistent-shop-orders-shipped"
x-kurkik:
pulsar:
operation:
security:
- billing
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-enriched:
action: send
channel:
$ref: "#/channels/persistent-shop-orders-enriched"
x-kurkik:
pulsar:
operation:
security: []
processors:
- type: function
name: shop/orders/enrich
server: standalone
producerConfiguration: {}
send_persistent-shop-orders-paid:
action: send
channel:
$ref: "#/channels/persistent-shop-orders-paid"
x-kurkik:
pulsar:
operation:
security: []
producerConfiguration: {}
send_persistent-shop-orders-raw:
action: send
channel:
$ref: "#/channels/persistent-shop-orders-raw"
x-kurkik:
pulsar:
operation:
security: []
producerConfiguration: {}
send_persistent-shop-orders-shipped:
action: send
channel:
$ref: "#/channels/persistent-shop-orders-shipped"
x-kurkik:
pulsar:
operation:
security: []
producerConfiguration: {}

Download source.yaml

target.yaml, 365 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:
schema-autoupdate: "on"
tenants:
- tenant: public
adminRoles: []
allowedClusters:
- standalone
- tenant: shop
adminRoles:
- shop-admin
allowedClusters:
- standalone
security:
- security: NONE
tls: false
acl:
- role: stale
resourceType: topic
name: persistent://shop/orders/paid
actions:
- consume
consumers:
- subscription: audit-log
type: Shared
topics:
- persistent://shop/orders/raw
processor: sink shop/orders/audit-log
- subscription: legacy
topics:
- persistent://shop/orders/paid
consumers: []
producers: []
functions: []
sources: []
sinks:
- tenant: shop
namespace: orders
name: audit-log
className: com.github.pakisan.kurkik.pulsar.fixtures.AuditLog
inputs:
- persistent://shop/orders/raw
subscriptionName: audit-log
parallelism: 1
processingGuarantees: ATLEAST_ONCE
channels:
- $ref: "#/channels/persistent-shop-orders-raw"
roles: []
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
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-enriched:
address: persistent://shop/orders/enriched
bindings:
pulsar:
bindingVersion: 0.1.0
namespace: orders
persistence: persistent
x-kurkik:
pulsar:
channel:
topic: persistent://shop/orders/enriched
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
messages:
persistent-shop-orders-paid:
payload:
schemaFormat: application/vnd.apache.avro;version=1.9.0
schema:
type: record
name: Payment
namespace: shop
fields:
- name: order
type: string
- name: paid
type: boolean
name: persistent-shop-orders-paid
title: persistent://shop/orders/paid
summary: "Schema read from Pulsar's own registry: AVRO, version 0."
x-kurkik:
pulsar:
message:
schemaType: AVRO
schemaVersion: 0
schemaIdLocation: metadata
schemaLookupStrategy: topic
schemaCompatibility: FULL
key:
type: string
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"
persistent-shop-orders-raw:
address: persistent://shop/orders/raw
messages:
persistent-shop-orders-raw:
payload:
type: string
name: persistent-shop-orders-raw
title: persistent://shop/orders/raw
summary: "Schema read from Pulsar's own registry: STRING, version 0."
x-kurkik:
pulsar:
message:
schemaType: STRING
schemaVersion: 0
schemaIdLocation: metadata
schemaLookupStrategy: topic
schemaCompatibility: FULL
key:
type: string
bindings:
pulsar:
bindingVersion: 0.1.0
namespace: orders
persistence: persistent
x-kurkik:
pulsar:
channel:
topic: persistent://shop/orders/raw
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-ticks:
address: persistent://shop/orders/ticks
bindings:
pulsar:
bindingVersion: 0.1.0
namespace: orders
persistence: persistent
x-kurkik:
pulsar:
channel:
topic: persistent://shop/orders/ticks
tenant: shop
namespace: orders
persistence: persistent
partitions: 0
geo-replication:
- standalone
topicConfiguration:
partitions: 0
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-enriched:
action: receive
channel:
$ref: "#/channels/persistent-shop-orders-enriched"
x-kurkik:
pulsar:
operation:
security: []
consumerConfiguration: {}
receive_persistent-shop-orders-paid:
action: receive
channel:
$ref: "#/channels/persistent-shop-orders-paid"
x-kurkik:
pulsar:
operation:
groupId:
type: string
enum:
- legacy
security:
- stale
consumerConfiguration: {}
receive_persistent-shop-orders-raw:
action: receive
channel:
$ref: "#/channels/persistent-shop-orders-raw"
x-kurkik:
pulsar:
operation:
groupId:
type: string
enum:
- audit-log
security: []
processors:
- type: sink
name: shop/orders/audit-log
server: standalone
consumerConfiguration: {}
receive_persistent-shop-orders-ticks:
action: receive
channel:
$ref: "#/channels/persistent-shop-orders-ticks"
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-enriched:
action: send
channel:
$ref: "#/channels/persistent-shop-orders-enriched"
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: {}
send_persistent-shop-orders-raw:
action: send
channel:
$ref: "#/channels/persistent-shop-orders-raw"
x-kurkik:
pulsar:
operation:
security: []
producerConfiguration: {}
send_persistent-shop-orders-ticks:
action: send
channel:
$ref: "#/channels/persistent-shop-orders-ticks"
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 topics create persistent://shop/orders/enriched
pulsar-admin --admin-url http://pulsar-a:8080 topics create persistent://shop/orders/raw
pulsar-admin --admin-url http://pulsar-a:8080 topics create persistent://shop/orders/shipped
pulsar-admin --admin-url http://pulsar-a:8080 namespaces set-message-ttl shop/orders --messageTTL 3600
pulsar-admin --admin-url http://pulsar-a:8080 namespaces grant-permission shop/orders --role billing --actions consume
pulsar-admin --admin-url http://pulsar-a:8080 topics create-subscription persistent://shop/orders/created --subscription audit --messageId earliest
pulsar-admin --admin-url http://pulsar-a:8080 schemas upload persistent://shop/orders/paid -f schema.json # {"type": "AVRO", "schema": "{\"type\":\"record\",\"name\":\"Payment\",\"namespace\":\"shop\",\"fields\":[{\"name\":\"order\",\"type\":\"string\"},{\"name\":\"paid\",\"type\":\"boolean\"}]}"}
pulsar-admin --admin-url http://pulsar-a:8080 schemas upload persistent://shop/orders/paid -f schema.json # {"type": "AVRO", "schema": "{\"type\":\"record\",\"name\":\"Payment\",\"namespace\":\"shop\",\"fields\":[{\"name\":\"order\",\"type\":\"string\"},{\"name\":\"paid\",\"type\":\"boolean\"},{\"name\":\"note\",\"type\":[\"null\",\"string\"],\"default\":null}]}"}
pulsar-admin --admin-url http://pulsar-a:8080 packages upload function://shop/orders/enrich@0 --path kurkik-pulsar-processors.jar --description 'kurkik fixtures'
pulsar-admin --admin-url http://pulsar-a:8080 functions create --tenant shop --namespace orders --name enrich --jar function://shop/orders/enrich@0 --classname com.github.pakisan.kurkik.pulsar.fixtures.Enrich --inputs persistent://shop/orders/created --output persistent://shop/orders/enriched --subs-name enrich --parallelism 1
pulsar-admin --admin-url http://pulsar-a:8080 packages upload sink://shop/orders/audit-log@0 --path kurkik-pulsar-processors.jar --description 'kurkik fixtures'
pulsar-admin --admin-url http://pulsar-a:8080 sinks create --tenant shop --namespace orders --name audit-log --archive sink://shop/orders/audit-log@0 --classname com.github.pakisan.kurkik.pulsar.fixtures.AuditLog --inputs persistent://shop/orders/raw --subs-name audit-log

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 topics create persistent://shop/orders/enriched
pulsar-admin --admin-url http://pulsar-b:8080 topics create persistent://shop/orders/raw
pulsar-admin --admin-url http://pulsar-b:8080 topics create persistent://shop/orders/ticks
pulsar-admin --admin-url http://pulsar-b:8080 topics grant-permission persistent://shop/orders/paid --role stale --actions consume
pulsar-admin --admin-url http://pulsar-b:8080 topics create-subscription persistent://shop/orders/paid --subscription legacy --messageId earliest
pulsar-admin --admin-url http://pulsar-b:8080 schemas upload persistent://shop/orders/paid -f schema.json # {"type": "AVRO", "schema": "{\"type\":\"record\",\"name\":\"Payment\",\"namespace\":\"shop\",\"fields\":[{\"name\":\"order\",\"type\":\"string\"},{\"name\":\"paid\",\"type\":\"boolean\"}]}"}
pulsar-admin --admin-url http://pulsar-b:8080 packages upload function://shop/orders/enrich@0 --path kurkik-pulsar-processors.jar --description 'kurkik fixtures'
pulsar-admin --admin-url http://pulsar-b:8080 packages upload sink://shop/orders/audit-log@0 --path kurkik-pulsar-processors.jar --description 'kurkik fixtures'
pulsar-admin --admin-url http://pulsar-b:8080 sinks create --tenant shop --namespace orders --name audit-log --archive sink://shop/orders/audit-log@0 --classname com.github.pakisan.kurkik.pulsar.fixtures.AuditLog --inputs persistent://shop/orders/raw --subs-name audit-log

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 \
--package function:shop/orders/enrich=function://shop/orders/enrich@0 \
--package sink:shop/orders/audit-log=sink://shop/orders/audit-log@0 > a.yaml # source.yaml (and b's, before: target.yaml)
# --package: the package each function, source or sink runs, as the build that published it knows - Pulsar's admin API
# never says which package a processor was deployed from, so the export is told
kurkik pulsar sync a.yaml b --all --overwrite --revoke --delete --dry-run # plan.txt (and -o json: plan.json)
kurkik pulsar sync a.yaml b --all --overwrite --revoke --delete --yes # apply.txt, and the reverse patch: rollback.yaml
kurkik pulsar diff a.yaml b --all # 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