如何从Localhost(例如Cassandra)上直接访问Localhost Kubernetes上的状态POD端口 - 需要什么路由?
我想在Localhost上使用Kubernetes构建一些测试环境(可以是Docker桌面。Minikube,...)。我想将我的客户连接到Local -Host K8S集群中的Cassandra的3个实例。 cassandra是示例,它在etcd,redis,...或任何statefulset
中可能相同。
- 我在Localhost Kubernetes上的同一端口上创建了
statefulset
。 - 我创建
服务
以暴露每个吊舱。
我应该在用使用三个不同的名称Cassandra-0
,Cassandra-1
,Cassandra-2
和同一端口的情况下进行操作。这是驱动程序所要求的 - 我无法转发单个端口,因为驾驶员需要在同一端口上运行所有实例。
因此,应该是Cassandra-0:9042
,Cassandra-1:9042
,Cassandra-0:9042
。
我想通过使用 ...-我不知道在K8S中使用什么 - 也许是服务。
I want to build some testing environment with use Kubernetes on localhost (can be Docker Desktop. minikube, ...). I want to connect my client to 3 instances of Cassandra inside localhost K8s cluster. Cassandra is example it can be same in etcd, redis, ... or any StatefulSet
.
- I created
StatefulSet
with 3 replicas on same ports on localhost Kubernetes. - I create
Services
to expose each pod.
What I should do next to route traffic with use three different names cassandra-0
, cassandra-1
, cassandra-2
and same port. This is required by driver - I can not forward individual ports since driver require to run all instances on same port.
So it should be cassandra-0:9042
, cassandra-1:9042
, cassandra-0:9042
.
To shows this I create some drawing to explain it graphically.
I want achieve red line connection with use something
... - I do not know what to use in K8s - maybe services.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我要说的是,您应该定义一个节点端口并将您的请求发送到Localhost:NodePort
只需更改您的端口,以便它们满足您的需求。
如果您已经创建了一个端口的服务,请获取所有终点,然后尝试将流量转向它们。
I would say you should define a node port and send your request to localhost:NodePort
Just change your ports so they fit your needs.
If you already created a service with ports exposed, get all endpoints and try turn traffic towards them.