Skip to content

Compare schema versions between two registries

One registry is a version ahead. Does Kurkik notice?

Terminal recording of kurkik kafka diff

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

Terminal window
kurkik kafka diff a b --schemas
a vs b
cluster MkU3OEVBNTcwNTJENDM2Qk
Schemas
~ customers.updated payload - The value schemas differ (customers.updated-value v1 and customers.updated-value v2). (a: v1 JSON Schema, b: v2 JSON Schema)
~ customers.updated structure - The structures differ in 1 field(s): email. (a: JSON Schema, b: JSON Schema)
~ customers.updated payload.email - email is only on b. (a: (absent), b: string, optional)
~ customers.updated versions - a has 1 version(s) and b 2. (a: 1, b: 2)
+ customers.updated version 2 - Version 2 (v2 JSON Schema) is only on b. (b: v2 JSON Schema)
~ orders.created payload - The value schemas differ (orders.created-value v1 and orders.created-value v2). (a: v1 Avro, b: v2 Avro)
~ orders.created structure - The structures differ in 1 field(s): note. (a: Avro, b: Avro)
~ orders.created payload.note - note is only on b. (a: (absent), b: string, optional)
~ orders.created versions - a has 1 version(s) and b 2. (a: 1, b: 2)
+ orders.created version 2 - Version 2 (v2 Avro) is only on b. (b: v2 Avro)
~ payments.settled payload - The value schemas differ (payments.settled-value v1 and payments.settled-value v2). (a: v1 Protobuf, b: v2 Protobuf)
~ payments.settled structure - The structures differ in 1 field(s): currency. (a: Protobuf, b: Protobuf)
~ payments.settled payload.currency - currency is only on b. (a: (absent), b: string, optional)
~ payments.settled versions - a has 1 version(s) and b 2. (a: 1, b: 2)
+ payments.settled version 2 - Version 2 (v2 Protobuf) is only on b. (b: v2 Protobuf)
Notes
- Not compared: ACLs, groups, configuration. Add --acls --groups --configs, or --all, to compare them.
Drift: 12 changed · 3 unmanaged · 0 missing (drift) - 22 matched

Exit code 2: drift found, so a CI job can stop here.

Mark Means
~ both sides have it, but it differs
! only the first side has it
+ only the second side has it
Compare Command Result
two clusters kurkik kafka diff a b --schemas Drift: 12 changed · 3 unmanaged · 0 missing (drift) - 22 matched
a document and a cluster kurkik kafka diff a.yaml b --schemas Drift: 12 changed · 3 unmanaged · 0 missing (drift) - 22 matched
two documents kurkik kafka diff a.yaml b.yaml --schemas Drift: 12 changed · 3 unmanaged · 0 missing (drift) - 22 matched

Download the JSON report (-o json)

a.yaml, 240 lines
asyncapi: 3.0.0
info:
title: a Apache Kafka API
version: 1.0.0-SNAPSHOT
description: "Generated by reading the a cluster. Cluster id: MkU3OEVBNTcwNTJENDM2Qk."
servers:
broker-1:
host: a-kafka-1:9092
protocol: kafka
protocolVersion: "4.4"
bindings:
kafka:
bindingVersion: 0.5.0
schemaRegistryUrl: http://registry-a:8080
schemaRegistryVendor: apicurio
x-kurkik:
kafka:
server:
schemaRegistryUrl: http://registry-a:8080
schemaRegistryVendor: apicurio
security:
- security: PLAINTEXT
securityProtocol: PLAINTEXT
acl: []
groups: []
brokerConfiguration:
advertised.listeners: "INTERNAL://kafka-1:19092,EXTERNAL://a-kafka-1:9092"
authorizer.class.name: org.apache.kafka.metadata.authorizer.StandardAuthorizer
broker.id: "1"
controller.listener.names: CONTROLLER
controller.quorum.voters: 1@kafka-1:9093
group.initial.rebalance.delay.ms: "0"
inter.broker.listener.name: INTERNAL
listener.security.protocol.map: "INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT,CONTROLLER:PLAINTEXT"
listeners: "INTERNAL://0.0.0.0:19092,EXTERNAL://0.0.0.0:9092,CONTROLLER://0.0.0.0:9093"
min.insync.replicas: "1"
node.id: "1"
offsets.topic.replication.factor: "1"
process.roles: "broker,controller"
transaction.state.log.min.isr: "1"
transaction.state.log.replication.factor: "1"
clientConfiguration:
bootstrap.servers: a-kafka-1:9092
security.protocol: PLAINTEXT
groupConfiguration: {}
producerConfiguration: {}
consumerConfiguration: {}
channels:
customers.updated:
address: customers.updated
messages:
customers.updated-value:
payload:
schemaFormat: application/schema+json;version=draft-07
schema:
$schema: http://json-schema.org/draft-07/schema#
title: Customer
type: object
properties:
id:
type: string
required:
- id
name: customers.updated-value
title: customers.updated
summary: "Schema read from the Apicurio Registry: subject customers.updated-value,\
\ version 1."
bindings:
kafka:
bindingVersion: 0.5.0
schemaIdLocation: header
schemaLookupStrategy: TopicIdStrategy
x-kurkik:
kafka:
message:
schemaIdLocation: header
schemaLookupStrategy: TopicIdStrategy
schemaCompatibility: NONE
bindings:
kafka:
bindingVersion: 0.5.0
partitions: 3
replicas: 1
topicConfiguration:
cleanup.policy:
- compact
x-kurkik:
kafka:
channel:
topic: customers.updated
partitions: 3
replicas: 1
topicConfiguration:
cleanup.policy: compact
orders.created:
address: orders.created
messages:
orders.created-value:
payload:
schemaFormat: application/vnd.apache.avro;version=1.9.0
schema:
type: record
name: OrderCreated
namespace: com.shop.orders
fields:
- name: id
type: string
- name: total
type: long
name: orders.created-value
title: orders.created
summary: "Schema read from the Apicurio Registry: subject orders.created-value,\
\ version 1."
bindings:
kafka:
bindingVersion: 0.5.0
schemaIdLocation: header
schemaLookupStrategy: TopicIdStrategy
x-kurkik:
kafka:
message:
schemaIdLocation: header
schemaLookupStrategy: TopicIdStrategy
schemaCompatibility: NONE
bindings:
kafka:
bindingVersion: 0.5.0
partitions: 3
replicas: 1
topicConfiguration:
retention.ms: 604800000
x-kurkik:
kafka:
channel:
topic: orders.created
partitions: 3
replicas: 1
topicConfiguration:
retention.ms: "604800000"
payments.settled:
address: payments.settled
messages:
payments.settled-value:
payload:
schemaFormat: application/vnd.google.protobuf;version=3
schema: |
syntax = "proto3";
package com.shop.payments;
message PaymentSettled {
string id = 1;
int64 cents = 2;
}
name: payments.settled-value
title: payments.settled
summary: "Schema read from the Apicurio Registry: subject payments.settled-value,\
\ version 1."
bindings:
kafka:
bindingVersion: 0.5.0
schemaIdLocation: header
schemaLookupStrategy: TopicIdStrategy
x-kurkik:
kafka:
message:
schemaIdLocation: header
schemaLookupStrategy: TopicIdStrategy
schemaCompatibility: NONE
bindings:
kafka:
bindingVersion: 0.5.0
partitions: 3
replicas: 1
x-kurkik:
kafka:
channel:
topic: payments.settled
partitions: 3
replicas: 1
topicConfiguration:
min.insync.replicas: "1"
retention.bytes: "10737418240"
operations:
receive_customers.updated:
action: receive
channel:
$ref: "#/channels/customers.updated"
x-kurkik:
kafka:
operation:
security: []
consumerConfiguration: {}
groupConfiguration: {}
receive_orders.created:
action: receive
channel:
$ref: "#/channels/orders.created"
x-kurkik:
kafka:
operation:
security: []
consumerConfiguration: {}
groupConfiguration: {}
receive_payments.settled:
action: receive
channel:
$ref: "#/channels/payments.settled"
x-kurkik:
kafka:
operation:
security: []
consumerConfiguration: {}
groupConfiguration: {}
send_customers.updated:
action: send
channel:
$ref: "#/channels/customers.updated"
x-kurkik:
kafka:
operation:
security: []
producerConfiguration: {}
send_orders.created:
action: send
channel:
$ref: "#/channels/orders.created"
x-kurkik:
kafka:
operation:
security: []
producerConfiguration: {}
send_payments.settled:
action: send
channel:
$ref: "#/channels/payments.settled"
x-kurkik:
kafka:
operation:
security: []
producerConfiguration: {}

Download a.yaml

b.yaml, 323 lines
asyncapi: 3.0.0
info:
title: b Apache Kafka API
version: 1.0.0-SNAPSHOT
description: "Generated by reading the b cluster. Cluster id: MkU3OEVBNTcwNTJENDM2Qk."
servers:
broker-1:
host: b-kafka-1:9092
protocol: kafka
protocolVersion: "4.4"
bindings:
kafka:
bindingVersion: 0.5.0
schemaRegistryUrl: http://registry-b:8080
schemaRegistryVendor: apicurio
x-kurkik:
kafka:
server:
schemaRegistryUrl: http://registry-b:8080
schemaRegistryVendor: apicurio
security:
- security: PLAINTEXT
securityProtocol: PLAINTEXT
acl: []
groups: []
brokerConfiguration:
advertised.listeners: "INTERNAL://kafka-1:19092,EXTERNAL://b-kafka-1:9092"
authorizer.class.name: org.apache.kafka.metadata.authorizer.StandardAuthorizer
broker.id: "1"
controller.listener.names: CONTROLLER
controller.quorum.voters: 1@kafka-1:9093
group.initial.rebalance.delay.ms: "0"
inter.broker.listener.name: INTERNAL
listener.security.protocol.map: "INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT,CONTROLLER:PLAINTEXT"
listeners: "INTERNAL://0.0.0.0:19092,EXTERNAL://0.0.0.0:9092,CONTROLLER://0.0.0.0:9093"
min.insync.replicas: "1"
node.id: "1"
offsets.topic.replication.factor: "1"
process.roles: "broker,controller"
transaction.state.log.min.isr: "1"
transaction.state.log.replication.factor: "1"
clientConfiguration:
bootstrap.servers: b-kafka-1:9092
security.protocol: PLAINTEXT
groupConfiguration: {}
producerConfiguration: {}
consumerConfiguration: {}
channels:
customers.updated:
address: customers.updated
messages:
customers.updated-value:
payload:
schemaFormat: application/schema+json;version=draft-07
schema:
$schema: http://json-schema.org/draft-07/schema#
title: Customer
type: object
properties:
id:
type: string
email:
type: string
required:
- id
name: customers.updated-value
title: customers.updated
summary: "Schema read from the Apicurio Registry: subject customers.updated-value,\
\ version 2."
bindings:
kafka:
bindingVersion: 0.5.0
schemaIdLocation: header
schemaLookupStrategy: TopicIdStrategy
x-kurkik:
kafka:
message:
schemaIdLocation: header
schemaLookupStrategy: TopicIdStrategy
schemaCompatibility: NONE
schemaVersions:
- version: 1
schemaFormat: application/schema+json;version=draft-07
schema:
$schema: http://json-schema.org/draft-07/schema#
title: Customer
type: object
properties:
id:
type: string
required:
- id
- version: 2
schemaFormat: application/schema+json;version=draft-07
schema:
$schema: http://json-schema.org/draft-07/schema#
title: Customer
type: object
properties:
id:
type: string
email:
type: string
required:
- id
bindings:
kafka:
bindingVersion: 0.5.0
partitions: 3
replicas: 1
topicConfiguration:
cleanup.policy:
- compact
x-kurkik:
kafka:
channel:
topic: customers.updated
partitions: 3
replicas: 1
topicConfiguration:
cleanup.policy: compact
orders.created:
address: orders.created
messages:
orders.created-value:
payload:
schemaFormat: application/vnd.apache.avro;version=1.9.0
schema:
type: record
name: OrderCreated
namespace: com.shop.orders
fields:
- name: id
type: string
- name: total
type: long
- name: note
type:
- "null"
- string
default: null
name: orders.created-value
title: orders.created
summary: "Schema read from the Apicurio Registry: subject orders.created-value,\
\ version 2."
bindings:
kafka:
bindingVersion: 0.5.0
schemaIdLocation: header
schemaLookupStrategy: TopicIdStrategy
x-kurkik:
kafka:
message:
schemaIdLocation: header
schemaLookupStrategy: TopicIdStrategy
schemaCompatibility: NONE
schemaVersions:
- version: 1
schemaFormat: application/vnd.apache.avro;version=1.9.0
schema:
type: record
name: OrderCreated
namespace: com.shop.orders
fields:
- name: id
type: string
- name: total
type: long
- version: 2
schemaFormat: application/vnd.apache.avro;version=1.9.0
schema:
type: record
name: OrderCreated
namespace: com.shop.orders
fields:
- name: id
type: string
- name: total
type: long
- name: note
type:
- "null"
- string
default: null
bindings:
kafka:
bindingVersion: 0.5.0
partitions: 3
replicas: 1
topicConfiguration:
retention.ms: 604800000
x-kurkik:
kafka:
channel:
topic: orders.created
partitions: 3
replicas: 1
topicConfiguration:
retention.ms: "604800000"
payments.settled:
address: payments.settled
messages:
payments.settled-value:
payload:
schemaFormat: application/vnd.google.protobuf;version=3
schema: |
syntax = "proto3";
package com.shop.payments;
message PaymentSettled {
string id = 1;
int64 cents = 2;
optional string currency = 3;
}
name: payments.settled-value
title: payments.settled
summary: "Schema read from the Apicurio Registry: subject payments.settled-value,\
\ version 2."
bindings:
kafka:
bindingVersion: 0.5.0
schemaIdLocation: header
schemaLookupStrategy: TopicIdStrategy
x-kurkik:
kafka:
message:
schemaIdLocation: header
schemaLookupStrategy: TopicIdStrategy
schemaCompatibility: NONE
schemaVersions:
- version: 1
schemaFormat: application/vnd.google.protobuf;version=3
schema: |
syntax = "proto3";
package com.shop.payments;
message PaymentSettled {
string id = 1;
int64 cents = 2;
}
- version: 2
schemaFormat: application/vnd.google.protobuf;version=3
schema: |
syntax = "proto3";
package com.shop.payments;
message PaymentSettled {
string id = 1;
int64 cents = 2;
optional string currency = 3;
}
bindings:
kafka:
bindingVersion: 0.5.0
partitions: 3
replicas: 1
x-kurkik:
kafka:
channel:
topic: payments.settled
partitions: 3
replicas: 1
topicConfiguration:
min.insync.replicas: "1"
retention.bytes: "10737418240"
operations:
receive_customers.updated:
action: receive
channel:
$ref: "#/channels/customers.updated"
x-kurkik:
kafka:
operation:
security: []
consumerConfiguration: {}
groupConfiguration: {}
receive_orders.created:
action: receive
channel:
$ref: "#/channels/orders.created"
x-kurkik:
kafka:
operation:
security: []
consumerConfiguration: {}
groupConfiguration: {}
receive_payments.settled:
action: receive
channel:
$ref: "#/channels/payments.settled"
x-kurkik:
kafka:
operation:
security: []
consumerConfiguration: {}
groupConfiguration: {}
send_customers.updated:
action: send
channel:
$ref: "#/channels/customers.updated"
x-kurkik:
kafka:
operation:
security: []
producerConfiguration: {}
send_orders.created:
action: send
channel:
$ref: "#/channels/orders.created"
x-kurkik:
kafka:
operation:
security: []
producerConfiguration: {}
send_payments.settled:
action: send
channel:
$ref: "#/channels/payments.settled"
x-kurkik:
kafka:
operation:
security: []
producerConfiguration: {}

Download b.yaml

How to build this setup yourself

Brokers

Cluster a

Terminal window
kafka-topics.sh --bootstrap-server a-kafka-1:9092 --create --topic orders.created --partitions 3 --replication-factor 1 --config retention.ms=604800000
kafka-topics.sh --bootstrap-server a-kafka-1:9092 --create --topic payments.settled --partitions 3 --replication-factor 1 --config min.insync.replicas=1 --config retention.bytes=10737418240
kafka-topics.sh --bootstrap-server a-kafka-1:9092 --create --topic customers.updated --partitions 3 --replication-factor 1 --config cleanup.policy=compact
api=http://registry-a:8080/apis/ccompat/v7; type='Content-Type: application/vnd.schemaregistry.v1+json' # apicurio/apicurio-registry-mem:2.6.5.Final
curl -X POST -H "$type" "$api/subjects/orders.created-value/versions" --data '{"schemaType":"AVRO","schema":"{\"type\":\"record\",\"name\":\"OrderCreated\",\"namespace\":\"com.shop.orders\",\"fields\":[{\"name\":\"id\",\"type\":\"string\"},{\"name\":\"total\",\"type\":\"long\"}]}"}'
curl -X POST -H "$type" "$api/subjects/customers.updated-value/versions" --data '{"schemaType":"JSON","schema":"{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"title\":\"Customer\",\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"string\"}},\"required\":[\"id\"]}"}'
curl -X POST -H "$type" "$api/subjects/payments.settled-value/versions" --data '{"schemaType":"PROTOBUF","schema":"syntax = \"proto3\";\npackage com.shop.payments;\n\nmessage PaymentSettled {\n string id = 1;\n int64 cents = 2;\n}\n"}'

Cluster b

Terminal window
kafka-topics.sh --bootstrap-server b-kafka-1:9092 --create --topic orders.created --partitions 3 --replication-factor 1 --config retention.ms=604800000
kafka-topics.sh --bootstrap-server b-kafka-1:9092 --create --topic payments.settled --partitions 3 --replication-factor 1 --config min.insync.replicas=1 --config retention.bytes=10737418240
kafka-topics.sh --bootstrap-server b-kafka-1:9092 --create --topic customers.updated --partitions 3 --replication-factor 1 --config cleanup.policy=compact
api=http://registry-b:8080/apis/ccompat/v7; type='Content-Type: application/vnd.schemaregistry.v1+json' # apicurio/apicurio-registry-mem:2.6.5.Final
curl -X POST -H "$type" "$api/subjects/orders.created-value/versions" --data '{"schemaType":"AVRO","schema":"{\"type\":\"record\",\"name\":\"OrderCreated\",\"namespace\":\"com.shop.orders\",\"fields\":[{\"name\":\"id\",\"type\":\"string\"},{\"name\":\"total\",\"type\":\"long\"}]}"}'
curl -X POST -H "$type" "$api/subjects/customers.updated-value/versions" --data '{"schemaType":"JSON","schema":"{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"title\":\"Customer\",\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"string\"}},\"required\":[\"id\"]}"}'
curl -X POST -H "$type" "$api/subjects/payments.settled-value/versions" --data '{"schemaType":"PROTOBUF","schema":"syntax = \"proto3\";\npackage com.shop.payments;\n\nmessage PaymentSettled {\n string id = 1;\n int64 cents = 2;\n}\n"}'
curl -X POST -H "$type" "$api/subjects/orders.created-value/versions" --data '{"schemaType":"AVRO","schema":"{\"type\":\"record\",\"name\":\"OrderCreated\",\"namespace\":\"com.shop.orders\",\"fields\":[{\"name\":\"id\",\"type\":\"string\"},{\"name\":\"total\",\"type\":\"long\"},{\"name\":\"note\",\"type\":[\"null\",\"string\"],\"default\":null}]}"}'
curl -X POST -H "$type" "$api/subjects/customers.updated-value/versions" --data '{"schemaType":"JSON","schema":"{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"title\":\"Customer\",\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"string\"},\"email\":{\"type\":\"string\"}},\"required\":[\"id\"]}"}'
curl -X POST -H "$type" "$api/subjects/payments.settled-value/versions" --data '{"schemaType":"PROTOBUF","schema":"syntax = \"proto3\";\npackage com.shop.payments;\n\nmessage PaymentSettled {\n string id = 1;\n int64 cents = 2;\n optional string currency = 3;\n}\n"}'

Compare

Terminal window
kurkik conn add kafka a --bootstrap a-kafka-1:9092 --registry-url http://registry-a:8080 --registry-vendor apicurio
kurkik conn add kafka b --bootstrap b-kafka-1:9092 --registry-url http://registry-b:8080 --registry-vendor apicurio
kurkik kafka export a --acls --groups --stdout > a.yaml
kurkik kafka export b --acls --groups --stdout > b.yaml
kurkik kafka diff a b --schemas # cluster-vs-cluster
kurkik kafka diff a.yaml b --schemas # document-vs-cluster
kurkik kafka diff a.yaml b.yaml --schemas # document-vs-document

All flags: kurkik kafka diff · more Apache Kafka diff examples