It’s common to setup a private Kubernetes environment using MiniKube with VirtualBox.
As it is intended to be a local installation, the services on Minikube are exposed to the localhost when using the command
But lets say you need to access remotely, or you have a web application and your host does not have a graphical interface. Here a quick solution.
After you create your service by exposing your deployment:
kubectl expose deployment myapp-deploy --name=myapp-service --type=NodePort --port=80
you simply need to
port-forward your running pod to your external network interface and let it listen on some port:
kubectl port-forward myapp-6b6cdf6b78-mdw94 --address 0.0.0.0 8080:80
and that’s it, you can see your host is listening in the new port:
patovm $ netstat -na | grep LISTEN tcp6 0 0 :::8080 :::* LISTEN
and it can be accessed, for example if you have a web app just point to the host’s external IP and port:
Similarly you can access your Minikube graphical dashboard.
First enable the dashboard and get the running pod name:
pato@patovm:~$ minikube addons enable dashboard * The 'dashboard' addon is enabled pato@patovm:~$ kubectl get pods --namespace=kubernetes-dashboard NAME READY STATUS RESTARTS AGE dashboard-metrics-scraper-84bfdf55ff-5zw5d 1/1 Running 0 28s kubernetes-dashboard-696dbcc666-bwwxt 1/1 Running 0 28s
now make that pod available externally by using the following
kubectl proxy --address 0.0.0.0 kubernetes-dashboard-696dbcc666-bwwxt 8001:80 --namespace=kubernetes-dashboard --disable-filter=true Starting to serve on [::]:8001
and it can be accessed with the following address:
You can access your Minikube Services and Dashboard remotely.