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 test k8s integrations.

Why do we need local Kubernetes?

Before we start into how to get Kubernetes running in your local environment, we should first go over a few reasons why you might want to do that in the first place.

Running Kubernetes locally allows you to:

  • Develop and test Kubernetes manifests on an ephemeral cluster
  • Install and test addons like different ingress controllers
  • Try external tools (like ShuttleOps) without adding a real cluster

Think of it as a development sandbox environment that you can setup for free on your own computer!

Suitable K8s Distributions

There are several projects that allow for running a Kubernetes cluster locally. This tutorial will initially focus on using minikube which is an official Kubernetes project and easy to get up and running.

Two other interesting options are:

  • k3s – a lightweight, production ready distribution focusing on the Edge and IOT
  • k0s – a “batteries included” distribution that packages all required k8s components in a single binary
Like what you’re reading?

Subscribe to ShuttleOps and be the first receive notifications on new blogs, releases, features and technology integrations.

Prerequisites

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 virtualbox as it is a well supported minikube driver on Mac, Linux, and Windows.
  • ngrok – Used for exposing the kubernetes API to the internet

Install Minikube

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

Pass the --driver=virtualbox flag to tell minikube the driver it should use:

The 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. We will demonstrate this by connecting your local cluster to ShuttleOps.

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):

Deploy to your development cluster

Firstly, you will need to create a ShuttleOps account for free before we can connect the cluster.

Create a ShuttleOps service account

These commands will output a token.txt file with your token inside:

This command will output a cluster-config.txt file that contains the cluster CA certificate:

The CA certificate will be shown as certificate-authority-data.

Set up the connection

To add a Kubernetes connection navigate to the connect page and add a new Kubernetes connection.

The form data should be filled out using these values:

Get Deploying

Once you’ve saved the connection, head over to the deploy section and start creating deployment pipelines!


Greg Schofield

Greg Schofield

Senior DevOps Specialist at ShuttleOps
Greg is a developer at ShuttleOps and has spent years helping clients solve complex DevOps challenges across many different technologies and platforms. Recently, Greg and the team have been translating the knowledge they've gathered in the field, into a new and innovative solution that simplifies and automates the end-to-end application delivery process.

  • LinkedIn

Related Posts

The ShuttleOps Factor

DevOps February 2, 2021

In the DevOps space, we all too often focus on the technical tools and practices that you should adopt...

Continue reading

How To Dockerize an Angular Application with...

Docker January 29, 2021

Introduction In this blog post, we will go through a step-by-step guide on how to write a multi-stage dockerfile...

Continue reading

What’s the Difference Between...

Blog January 28, 2021

In the DevOps world, the terms continuous integration, continuous delivery, and continuous deployment are quite common. What’s also quite...

Continue reading