简体   繁体   English

无法在裸机“ Localhost”上公开Kubernetes服务

[英]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.

相关问题 如何从裸机集群公开kubernetes服务 - How to expose kubernetes service from bare metal cluster 如何在裸机安装上从外部访问kubernetes服务 - How to access kubernetes service externally on bare metal install 从裸机 kubernetes 集群向 Internet 公开服务 - Exposing service to the internet from a bare metal kubernetes cluster 裸机中的集群间服务发现 Kubernetes 机器 - Inter-Cluster Service Discovery in Bare Metal Kubernetes Machines 裸机上的 Kubernetes 集群 by kubeadm - Kubernetes cluster on bare metal by kubeadm Nginx Ingress Controller on Bare Metal 暴露问题 - Nginx Ingress Controller on Bare Metal expose problem 从我的裸机 k8s 节点向世界公开服务 - Expose service to the world from my bare metal k8s node 不可能在 kubernetes(裸机)中连接到 elasticsearch - Impossible connect to elasticsearch in kubernetes(bare metal) 在裸机上从外部访问 kubernetes 中的服务的问题 - Issue with accessing services in kubernetes externally on bare metal 在带有 ClusterIP 服务和 kube-keepalive-vip 的裸机 Kubernetes 上使用 Traefik 2 没有 X-Forwarded-For - no X-Forwarded-For with Traefik 2 on bare metal Kubernetes with ClusterIP Service and kube-keepalive-vip
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM