This tutorial will go through the steps to create a Kubernetes developer sandbox using
minikube. We will also show you how to expose a
minikube cluster using ngrok so you can access your Kubernetes cluster from the internet.
Why might we want to expose
minikube to the internet?
Before we start into how to get
minikube setup with an
ngrok tunnel, we should first go over a few reasons why you might want to do that in the first place.
minikube with a
ngrok tunnel allows you to:
- Test out some cloud-based SaaS platforms like WeaveWorks, OctopusDeploy, etc. without using a cloud-based Kubernetes cluster
- Perform PoCs with different ingress controllers
- Develop and test Kubernetes manifests on an ephemeral cluster
Think of it as a development sandbox environment that you can setup for free on your own computer!
To follow along with this tutorial your computer should have at least:
- 2 CPUs or more
- 4GB of free memory
- 20GB of free disk space
- kubectl – the Kubernetes CLI
- virtualbox – We recommend
virtualboxas it is a well supported minikube driver on Mac, Linux, and Windows.
- ngrok – Used for exposing the kubernetes API to the internet
Installing minikube is easy since it is a standalone binary. Mac and Windows both have official installs available from a package manager. Linux distros are should use
curl to download the binary.
Start the cluster
--driver=virtualbox flag to tell minikube the driver it should use:
config set driver command will allow you to set the default so you can omit the flag next time:
At this point you should use
minikube status and make sure the output looks like this:
Exposing the Kubernetes API to the internet
Now that our cluster is running locally, we can use
ngrok to make it accessible to the internet. By making it accessible to the internet, you can test integrating with CI tools or try a SaaS platform for free.
The first thing we need to do is use
kube-proxy to proxy requests to the API from localhost:
Next we can open an
ngrok tunnel (port 8001 is the default Kubernetes API port):
ngrok UI will output an HTTPS address that points directly to your
minikube‘s API port. You can now use that URL to run
kubectl commands against.