Home > OS >  OpenShift Kafka connect REST API not accessible from outside through Route URL
OpenShift Kafka connect REST API not accessible from outside through Route URL

Time:11-24

I am running Kafka connect worker from Openshift cluster and able to access the connector APIs from the PODs terminal like below (listener in connect-distributed.properties as https://localhost:20000):

sh-4.2$ curl -k -X GET https://localhost:20000
{"version":"5.5.0-ce","commit":"dad78e2df6b714e3","kafka_cluster_id":"XojxTYmbTXSwHguxJ_flWg"}

I have created OpenShift routes with below config:

- kind: Route
    apiVersion: v1
    metadata:
      name: '${APP_SHORT_NAME}-route'
      labels:
        app: '${APP_SHORT_NAME}'
      annotations:
        description: Route for application's http service.
    spec:
      host: '${APP_SHORT_NAME}.${ROUTE_SUFFIX}'
      port:
        targetPort: 20000-tcp
      tls:
        termination: reencrypt
        destinationCACertificate: '${DESTINATION_CA_CERTIFICATE}'
      to:
        kind: Service
        name: '${APP_NAME}-service'

Port 20000 is exposed from Dockerfile but the route URL is throwing below error instead:

Possible reasons you are seeing this page:

The host doesn't exist. Make sure the hostname was typed correctly and that a route matching this hostname exists.

The host exists, but doesn't have a matching path. Check if the URL path was typed correctly and that the route was created using the desired path.

Route and path matches, but all pods are down. Make sure that the resources exposed by this route (pods, services, deployment configs, etc) have at least one pod running

Same OpenShift route URL works fine with a normal Spring boot service but Kafka connect worker URL is not getting bind to the Route URL create as above. (Note the Kafka connect worker is running fine along with the logs in the OpenShift pods)

CodePudding user response:

Set the listeners back to the default of bind-address 0.0.0.0 so that external connections can be accepted.

If you need a different port, you can use port forwarding in the k8s service, rather than do that at the application config.

If you're not using Strimzi (which doesn't look like you are, based on 5.5.0-ce), you'll also want to add this env-var so a cluster can be formed.

- name: CONNECT_REST_ADVERTISED_HOST_NAME
  valueFrom:
    fieldRef:
      fieldPath: status.podIP
  • Related