How to override schema registry master accessing hostname and port

9/21/2021

I setting up 2 schema registry on different k8s cluster and using nodeport service for communication between 2 clusters. I followed steps here for multi-datacenter schema registry: https://docs.confluent.io/platform/6.0.0/schema-registry/multidc.html.

When the secondary schema registry (with leader.eligibility: false) trying to forward new schema registration to primary schema registry, it use internal IP of primary schema registry which end up failing. How do I able to tell my secondary schema registry to use the accessible hostname and port number to connect primary schema registry?

I using image confluentinc/cp-schema-registry:6.0.0.

Primary schema registry configuration:

host.name=10.X.X.X (internal IP of schema registry pod)
kafkastore.group.id=my-schema-registry
kafkastore.bootstrap.servers=PLAINTEXT://my-cluster-kafka-bootstrap:9092 (Primary Kafka Broker Internal Hostname)
avro.compatibility.level=NONE
schema.compatibility.level=NONE

Secondary schema registry configuration:

host.name=10.X.X.X (internal IP of schema registry pod)
kafkastore.group.id=my-schema-registry
kafkastore.bootstrap.servers=PLAINTEXT://10.X.X.X:30292 (Primary Kafka Broker IP)
avro.compatibility.level=NONE
schema.compatibility.level=NONE
leader.eligibility=false

Error throw in schema registry logs when forwarding the registration request.

ERROR Failed to send HTTP request to endpoint: http://10.X.X.X:8081/subjects/XXX/versions (io.confluent.kafka.schemaregistry.client.rest.RestService)
java.net.SocketTimeoutException: connect timed out
   at ... 

Note: internal port 8081 is not accessible from another cluster, so I had expose different port number using NodePort Service for both schema registry on different cluster. This is the reason I want override the port number accessing to master from secondary schema registry.

-- tboom
confluent-schema-registry
kubernetes

1 Answer

9/28/2021

After some researching, there is no way to override which endpoint or leader endpoint on secondary schema registry. But we can override endpoint details on primary schema registry will share with secondary schema registry when forwarding request.

To override hostname, use host.name.

To override port, add new port number under listeners.

Refer https://docs.confluent.io/platform/current/schema-registry/installation/config.html#

listeners: http://0.0.0.0:30300,http://0.0.0.0:8081
host.name: <k8s IP address>

*30300 - port number use in NodePort

I need to remain 8081 in list of listeners which required by schema registry.

-- tboom
Source: StackOverflow