OpenShift Kafka connect REST API不能通过Route URL从外部访问



我正在从Openshift集群运行Kafka connect worker,并能够从pod终端访问连接器api,如下所示(connect-distributed.properties中的侦听器作为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"}

我用下面的配置创建了OpenShift路由:

- 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'

端口20000从Dockerfile暴露,但是路由URL抛出以下错误:

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

相同的OpenShift路由URL在正常的Spring启动服务中工作得很好,但是Kafka connect worker的URL没有绑定到如上所述创建的路由URL。(注意Kafka connect worker与OpenShift pod中的日志一起运行良好)

listeners设置为默认绑定地址0.0.0.0,以便接受外部连接

如果您需要一个不同的端口,您可以在k8s服务中使用端口转发,而不是在应用程序配置中这样做。

如果您没有使用Strimzi(看起来不像,基于5.5.0-ce),您还需要添加这个env-var,以便可以形成集群。

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

最新更新