[英]Unable to expose Kubernetes service on Bare Metal “Localhost”
I am new to Kubernetes and have a basic question. 我是Kubernetes的新手,有一个基本问题。 I installed the Canonical Distribution of Kubernetes on a bare metal Ubuntu "Localhost" setup with LXD.
我在带有LXD的裸机Ubuntu“ Localhost”安装程序上安装了Kubernetes的Canonical Distribution。
I am able to run a simple deployment/service for a NGINX cluster. 我能够为NGINX集群运行一个简单的部署/服务。 However, I am confused as to how I can actually expose it externally using my server hostip.
但是,我对于如何使用服务器hostip在外部实际公开它感到困惑。
For instance: 例如:
kubectl run my-nginx --image=nginx --replicas=3 --port=80
kubectl expose deployment my-nginx --type=NodePort
kubectl describe services my-nginx --> Shows NodePort as 31198
I can successfully run a CURL to any of the Worker Nodes: 我可以成功地对任何工作节点运行CURL:
curl 10.112.134.139:31198
curl 10.112.134.41:31198
However, my hostip is 192.168.XY How can I actually expose this so I can access using the HOSTIP? 但是,我的hostip是192.168.XY我如何才能真正公开该地址,以便可以使用HOSTIP访问?
From what you describe, it looks like, in your local environment, configured a "containerized cluster". 根据您的描述,它看起来像是在本地环境中配置了“包含容器的群集”。 Therefore, you can access the NodePort accessing these containerized worker nodes, but the host IP itself (as there is nothing configured in that local host, right?).
因此,您可以访问NodePort来访问这些容器化工作节点,但是访问主机IP本身(因为该本地主机中没有配置任何内容,对吗?)。
So, what you would need to do is to establish a way to forward traffic from the Host to the "containerized cluster", so the NodePort is accessible. 因此,您需要做的是建立一种将流量从主机转发到“容器化群集”的方法,以便可以访问NodePort。
One way that comes to mind would be, in the machine you are trying to access from, to configure a route like this 想到的一种方法是,在您尝试访问的计算机中,配置这样的路由
10.112.134.0/24 - gateway 192.168.XY 10.112.134.0/24-网关192.168.XY
sudo route add -net 10.112.134.0/24 gw 192.168.X.Y
Probably, you may need to check that the sysctl rule net.ip4.forward is enabled. 可能需要检查sysctl规则net.ip4.forward是否已启用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.