<p>I have install a kubernetes cluster using three VMs in virtualBox, and my host machine's IP is  192.168.50.166, and the node information in cluster is</p>
<pre><code>vm1 192.168.50.28  worker-node-1 
vm2 192.168.50.29  worker-node-2 
vm3 192.168.50.30  master-node 
</code></pre>
<p>if I can have a single public IP (140.112.1.1) in my host machine, how can I expose my services like</p>
<pre><code>http://140.112.1.1:xxxx/services
</code></pre>
<p>I think maybe I should buy another network interface in my host machine and assign public IP to this interface, but I don't known how to communicate with my cluster.</p>

tom
<p>What you are searching for is the LoadBalancer service and the Ingress resource.</p>
<p>Kubernetes can offer LoadBalancing service (<a href="https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer</a>), which basically acts as a way to transfer traffic from an external LoadBalancer to the backend Pods.</p>
<p>If you are hosting your Kubernetes cluster on top of a cloud service (Azure, Google and so on), there are a good amount of chances that you already have something that provides Load Balancer functionalities for your cluster.</p>
<p>If that's not the case and you want to host a Load Balancer service on top of the Kubernetes cluster, so that all your nodes partecipate in serving the public IP (or more than one public IP), a common approach is to deploy MetalLB on Kubernetes (<a href="https://metallb.universe.tf/" rel="nofollow noreferrer">https://metallb.universe.tf/</a>)</p>
<p>Second, by using Ingress resources (<a href="https://kubernetes.io/docs/concepts/services-networking/ingress/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/ingress/</a>), it is possible to manage external access to different Pods (and Services) based on the path of the request, typically HTTP or HTTPS.</p>
<p>It's basically a way to route incoming traffic to different Services (and different Pods) in the cluster, based on the path of the request, plus can offer SSL and a lot of other functionalities.</p>
<p>A common approach to serve Ingress resources on a cluster, is by using NGINX Ingress (<a href="https://kubernetes.github.io/ingress-nginx/" rel="nofollow noreferrer">https://kubernetes.github.io/ingress-nginx/</a>)</p>
<p>With the combination of LoadBalancer + Ingress you can expose all your services behind a LoadBalancer attached to an external IP address, everything nicely in HTTP or HTTPS with certificates and so on.</p>
<p>With the supposition that you are hosting your Kubernetes cluster on almost-bare-metal (normal VMs like if they were bare-metal machines), you could:</p>
<ul>
<li>Have the public address you have at your disposal available for the VMs to use on their network interfaces</li>
<li>Install MetalLB on the cluster, this will provide internal LoadBalancing, you can specify which IP range (or single IP) it can use</li>
<li>Install NGINX Ingress on the cluster, this will provide support for Ingress resources. When installing this, the nginx-controller should receive the external IP in LoadBalancing by MetalLB</li>
<li>Lastly, create an Ingress to serve all the services that you want under the paths that you want. If everything works correctly, the nginx-controller should start serving your services on the external IP address</li>
</ul>
