Upgrade SR to version 8.1 to support the FORWARD mode, but retain running against CP 7.9.5 Kafka cluster
-
Copy the environment template and configure your credentials:
cp .env.example .env # Edit .env with your actual Confluent Cloud credentials -
Load environment variables (for running curl commands below):
source load-env.sh # This exports all variables from .env so they're available in your shell
-
Start the services:
docker-compose up -d
After the container is up, put Schema Registry into FORWARD mode for the desired context (global or context-specific) using the REST API (from the host or inside the container):
- Global (all contexts):
curl --request PUT \
-H "Content-Type: application/vnd.schemaregistry.v1+json" \
--data '{"mode":"FORWARD"}' \
http://localhost:8081/mode/:.__GLOBAL:
# {"mode":"FORWARD"}- Specific context NOT SUPPORTED (e.g. .site1 pointing to context site1 in lsrc-9380d5):
curl --request PUT \
-H "Content-Type: application/vnd.schemaregistry.v1+json" \
--data '{"mode":"FORWARD"}' \
http://localhost:8081/mode/:.site1:
# {"error_code":42204,"message":"Forward mode only supported on global level"}% - Find local Kafka cluster ID
docker compose exec -it kafka /usr/bin/kafka-cluster cluster-id --bootstrap-server localhost:9092
# Cluster ID: vp3HUn57TzCTsAgk3EKg1QRegister this in CC if configuring USM fully
- Ensure CC context is READWRITE
curl --request PUT \
-u "${CC_SR_API_KEY}:${CC_SR_API_SECRET}" \
-H "Content-Type: application/vnd.schemaregistry.v1+json" \
--data '{"mode": "READWRITE"}' \
${CC_SR_ENDPOINT}/mode/${REMOTE_CONTEXT_PREFIX}
{"mode":"READWRITE"}- Check local mode
curl -X GET \
-H "Content-Type: application/vnd.schemaregistry.v1+json" \
http://localhost:8081/mode/:.site1:- Register a schema in CC SR
curl -X POST \
-u "${CC_SR_API_KEY}:${CC_SR_API_SECRET}" \
-H "Content-Type: application/vnd.schemaregistry.v1+json" \
--data "{\"schema\":$(jq -Rs . user.avsc)}" \
${CC_SR_ENDPOINT}/subjects/:.${REMOTE_CONTEXT_PREFIX}:danr-topic-value/versions
# {"id":100001}- Register a schema in CP SR
# Example: register an Avro schema under subject "my-topic-value"
curl -X POST \
-H "Content-Type: application/vnd.schemaregistry.v1+json" \
--data "{\"schema\":$(jq -Rs . user.avsc)}" \
http://localhost:8081/subjects/my-topic-value/versions
# {"id":1,"version":1,"guid":"7ff7b78f-baac-1a9b-11d3-652aa3916680","schemaType":"AVRO","schema":"{\"type\":\"record\",\"name\":\"User\",\"namespace\":\"example\",\"fields\":[{\"name\":\"id\",\"type\":\"string\"},{\"name\":\"name\",\"type\":\"string\"}]}"}- Read local schemas
curl -X GET \
-H "Content-Type: application/vnd.schemaregistry.v1+json" \
http://localhost:8081/subjects- Read CC SR schemas
curl -X GET \
-u "${CC_SR_API_KEY}:${CC_SR_API_SECRET}" \
-H "Content-Type: application/vnd.schemaregistry.v1+json" \
${CC_SR_ENDPOINT}/subjects- create importer
curl --request POST \
-H "Content-Type: application/vnd.schemaregistry.v1+json" \
--data "{
\"name\": \"usm-importer\",
\"subjects\": [\":.${REMOTE_CONTEXT_PREFIX}:*\"],
\"config\": {
\"schema.registry.url\": \"${CC_SR_ENDPOINT}\",
\"basic.auth.credentials.source\": \"USER_INFO\",
\"basic.auth.user.info\": \"${CC_SR_API_KEY}:${CC_SR_API_SECRET}\"
}
}" \
http://localhost:8081/importers
# {"name":"usm-importer"}- check they're being fetched
curl -X GET -H "Content-Type: application/vnd.schemaregistry.v1+json" http://localhost:8081/subjects
# ["danr-topic-value","my-topic-value"]