Schema Registry Replication
Configure schema replication to target cluster.
Found an issue? Feed it back to us at Github, on Slack, Ask Marios or email.
To execute K2K, you must agree to the EULA and secure a free license.
Accept the EULA by setting license.acceptEula
to true
.
Secure a free license by:
emailing [email protected] to receive a token within seconds
setting
license.token
with the received token
K2K supports migrating schemas from a source cluster to a destination cluster. This page covers the configuration steps required to enable this feature. For now K2K supports Schema Registries compatible with Confluent Schema Registry API.
Requirements
This tutorial assumes the following files exist (See Setting up for more details):
name: "my-first-replication"
features:
autoCreateControlTopics: enabled
autoCreateTopics: enabled
source:
kafka:
connection:
servers: "kafka-source:9092"
consumer:
"group.id": "k2k.my-first-k2k"
target:
kafka:
connection:
servers: "kafka-target:9092"
coordination:
kafka:
commit:
group: "k2k.my-first-k2k"
replication:
- source:
topic: ".*"
- sink:
topic: source
partition: source
To ensure a clean start, execute this command to reset any prior configurations from earlier tutorials.
docker compose down
Creating the source cluster topic
Execute these commands to create the "user-topic" topic and add data:
#create a topic
docker compose exec kafka-source \
./opt/kafka/bin/kafka-topics.sh \
--create \
--topic user-topic \
--partitions 5 \
--bootstrap-server 127.0.0.1:9092
#add some data and register the schema
docker compose exec -it registry-source \
kafka-avro-console-producer \
--bootstrap-server kafka-source:9092 \
--topic user-topic \
--property schema.registry.url="http://registry-source:8085" \
--property key.schema='{"type":"record","name":"userKey","fields":[{"name":"id","type":"int"}]}' \
--property value.schema='{"type":"record","name":"userRecord","fields":[{"name":"user_name","type":"string"}]}'
#paste this message
{"user_name": "my-name"}
Repeat with different routing strategies
When replicating schemas, K2K considers the record routing strategy. Thus, if you repeat the steps with different routing strategies, such as appending a suffix to the topic name, the replicated subjects will be named according to the routing rule.
For more information about record routing refer to: (Routing Records)
Last updated
Was this helpful?