<p>I have configured a Kubernetes cluster using kubeadm, by creating 3 Virtualbox nodes, each node running CentOS (master, node1, node2). Each virtualbox virtual machine is configured using 'Bridge' networking.
As a result, I have the following setup:</p>

<ol>
<li>Master node 'master.k8s' running at 192.168.19.87 (virtualbox)</li>
<li>Worker node 1 'node1.k8s' running at 192.168.19.88 (virtualbox)</li>
<li>Worker node 2 'node2.k8s' running at 192.168.19.89 (virtualbox</li>
</ol>

<p>Now I would like to access services running in the cluster from my local machine (the physical machine where the virtualbox nodes are running).</p>

<p>Running <code>kubectl cluster-info</code> I see the following output:</p>

<pre><code>Kubernetes master is running at https://192.168.19.87:6443
KubeDNS is running at ...
</code></pre>

<p>As an example, let's say I deploy the dashboard inside my cluster, how do I open the dashboard UI using a browser running on my physical machine?</p>

<p>The traditional way is to use <code>kubectl proxy</code> or a <code>Load Balancer</code>, but since you are in a <strong>development machine</strong> a <code>NodePort</code> can be used to publish the applications, as a Load balancer is not available in VirtualBox.</p>

<p>The following example deploys 3 replicas of an echo server running nginx and publishes the http port using a <code>NodePort</code>:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 3
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
        - name: my-echo
          image: gcr.io/google_containers/echoserver:1.8          
---

apiVersion: v1
kind: Service
metadata:
  name: nginx-service-np
  labels:
    name: nginx-service-np
spec:
  type: NodePort
  ports:
    - port: 8082        # Cluster IP http://10.109.199.234:8082
      targetPort: 8080  # Application port
      nodePort: 30000   # Example (EXTERNAL-IP VirtualBox IPs) http://192.168.50.11:30000/ http://192.168.50.12:30000/ http://192.168.50.13:30000/
      protocol: TCP
      name: http
  selector:
    app: nginx
</code></pre>

<p>You can access the servers using any of the VirtualBox IPs, like 
 <a href="http://192.168.50.11:30000" rel="nofollow noreferrer">http://192.168.50.11:30000</a> or  <a href="http://192.168.50.12:30000" rel="nofollow noreferrer">http://192.168.50.12:30000</a> or  <a href="http://192.168.50.13:30000" rel="nofollow noreferrer">http://192.168.50.13:30000</a></p>

<p>See a full example at <a href="https://www.itwonderlab.com/ansible-kubernetes-vagrant-tutorial/" rel="nofollow noreferrer">Building a Kubernetes Cluster with Vagrant and Ansible (without Minikube)</a>.</p>
