从SvelteKit访问Kubernetes中的Kafka

huangapple go评论66阅读模式
英文:

Accessing Kafka in Kubernetes from SvelteKit

问题

我正在构建一个具有Kafka支持的SvelteKit应用程序。我已经创建了一个kafka.js文件,并使用本地Kafka设置测试了Kafka支持,一切都成功。但是,当我将主题名称替换为运行在我们Kubernetes集群中的Kafka中的主题时,我没有看到任何响应。

我应该如何测试在Kubernetes集群中的Kafka与JS Web应用程序之间建立的连接?任何提示都会非常有帮助。到目前为止,仅使用控制台日志并不有帮助,因为Kafka本身没有被访问到。

英文:

I am building a SvelteKit application with Kafka Support. I have created a kafka.js file and tested the kafka support with a local kafka setup, which is successful. Now, When I replaced the topic name with a topic that is running in the kafka of our Kubernetes cluster, am not seeing any response.

How do I test this connection that is establishing between Kafka in Kubernetes cluster and the JS web application ? Any hints could be much helpful. Doing just console logs are not helpful so far because kafka itself not getting hit.

答案1

得分: 1

任何部署在相同命名空间的两个 Pod 可以使用本地服务名称进行通信。那么,这些代理是否有 Service 资源呢?

例如,假设您在 namespace: default 中,并且有 kafka-svc,那么您可以设置 bootstrap.servers: kafka-svc.svc.cluster.local

您还需要配置 Kafka 的 advertised.listeners。相关博客 - https://strimzi.io/blog/2019/04/17/accessing-kafka-part-1/

但这需要 NodeJS(或其他语言)后端,而不是 SvelteKit UI(无法连接到后端的 TCP 服务器,只能使用一些 HTTP 桥接)。您的 HTTP 选项包括一些自定义服务器,或者 Confluent REST Proxy、Strimzi Kafka Bridge 等等。但您已经被告知了这一点

英文:

Any two pods deployed in the same namespace can communicate using local service names. So, do the brokers have a Service resource?

For example, assuming you are in namespace: default, and you have kafka-svc, then you'd setup bootstrap.servers: kafka-svc.svc.cluster.local.

You also need to configure Kafka's advertised.listeners. Related blog - https://strimzi.io/blog/2019/04/17/accessing-kafka-part-1/

But this requires NodeJS (or other language) backend, and not SvelteKit UI (which cannot connect to backend TCP server, only use some HTTP bridge). Your HTTP options would include some custom server, or Confluent REST Proxy, Strimzi Kafka Bridge, etc. But you were already told this.

huangapple
  • 本文由 发表于 2023年2月10日 06:09:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/75404954.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定