通过无头服务和端点从Kubernetes到开发机
我正在尝试使用无头服务
endpoint
将群集中的流量转发到我的本地开发机器。我想在服务上的端口80上收听,并在端点上调用端口5002。我将其设置为这样:
我尝试curl http:// web:80
从我的端口80上的任何pod中的80 。如果我curl http:// web:5002
它成功通过并击中了我的开发机器。 targetPort
是否应该向Web:80
转到我的端口5002
上的端点?
一些附加信息:
- 同一本地网络中
- 我的群集和开发机在我使用的k3群集的
- ,我只是想模仿kubernetes在这里做什么的桥梁,
这是明显的yaml:
apiVersion: v1
kind: Service
metadata:
name: web
namespace: default
spec:
clusterIP: None
ports:
- name: web
port: 80
targetPort: 5002
---
apiVersion: v1
kind: Endpoints
metadata:
name: web
namespace: default
subsets:
- addresses:
- ip: $HOST_IP
ports:
- name: web
port: 5002
protocol: TCP
I'm trying to use a headless service
with an endpoint
to forward traffic from within my cluster to my local development machine. I want to listen on port 80 on the service and call port 5002 on the endpoint. I have it setup as so:
Headless Service (listening on port 80 with a targetPort of 5002):
Endpoint (pointing to my development computer on port 5002):
When I try to curl http://web:80
from any pod in my cluster on port 80 it times out. If I curl http://web:5002
it successfully goes through and hits my development machine. Shouldn't the targetPort
make the request to web:80
go to my endpoint on port 5002
?
Some additional info:
- My cluster and dev machine are in the same local network
- I'm using K3S on the cluster
- I'm just trying to emulate what Bridge For Kubernetes does
Here is the manifest yaml:
apiVersion: v1
kind: Service
metadata:
name: web
namespace: default
spec:
clusterIP: None
ports:
- name: web
port: 80
targetPort: 5002
---
apiVersion: v1
kind: Endpoints
metadata:
name: web
namespace: default
subsets:
- addresses:
- ip: $HOST_IP
ports:
- name: web
port: 5002
protocol: TCP
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我设法通过删除
clusterip:无
来使其工作。我的清单现在看起来像这样:I managed to get it to work by removing the
clusterIP: None
. My manifest now looks like this: