如何通过Localhost的DNS名称访问Kubernetes服务,哪个是Docker Desktop/Kubernetes?

发布于 2025-02-04 20:56:16 字数 766 浏览 4 评论 0原文

我有这样的配置localhost在上面安装了带有Kubernetes的Docker桌面。

例如,我部署了一些Cassandra服务器作为状态表,我创建了这样的服务,以使各个Pods从状态满集中揭露。我无法使用Cassandra服务,因为对于某些Cassandra操作,默认负载平衡是有毒的。我需要在无头服务或选定的种子吊舱中连接所有豆荚 - 在这种情况下,无近的选择是最佳选择。

apiVersion: v1
kind: Service
metadata:
  name: cassandra-0
spec:
  type: LoadBalancer
  selector:
    statefulset.kubernetes.io/pod-name: cassandra-0
  ports:
  - name: cql
    protocol: TCP
    port: 9042
    targetPort: 9042

我想将其暴露为Localhost内部的Cassandra-0。

我该怎么做才能以最简单的方式做到这一点?

我现在想象的,但也许不需要。

  1. 将一些Localhost DNS配置为Cassandra-0:9042点9042。
  2. 使用NGINX将流量路由到特定的裸露端口(9042,9043,...),用于(Cassandra-0,Cassandra-1,...)

我计划去使用Kubernetes中的POD从Local主持进行测试。

I have such configuration localhost on which is installed Docker Desktop with Kubernetes.

I deployed for example some cassandra server as statefulset I created such service to expose individual pods from statefulset. I can not use cassandra service since for some Cassandra operation default load balancing is toxic. I need to connect all pods in headless service or selected seed pods - proxyless option is the best choice in this case by design.

apiVersion: v1
kind: Service
metadata:
  name: cassandra-0
spec:
  type: LoadBalancer
  selector:
    statefulset.kubernetes.io/pod-name: cassandra-0
  ports:
  - name: cql
    protocol: TCP
    port: 9042
    targetPort: 9042

I want to expose it as cassandra-0.. inside localhost.

What should I do to make it in the easiest way?

What I imagine now but maybe it not need.

  1. Configure some localhost dns to point cassandra-0:9042 to port 9042.
  2. Use nginx to route traffic to specific exposed ports (9042,9043, ...) for (cassandra-0, cassandra-1, ...)

I plan to make test from localhost using pods in kubernetes.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文