Run Kubernetes On Your Laptop Within 30 Minutes

Step-by-step process to set up a local development environment on your laptop or desktop using Minikube and to run a Hello World website with MERN (MongoDB, Express, React, and Node.js) stack.

Hitesh Parashar
Feb 25 · 3 min read

This is an article in a series to build a software development stack that is quick, free, portable, and scalable.

What are containers, and why should you care?

Containers took the software infrastructure space by storm over the last few years.

Containers provide a portable packaging mechanism to bring all the dependencies required for running your software within one image and a container.

Developers can deploy container images across all of the container runtimes due to standards defined by Open Container Initiative for different platforms, including public cloud providers — AWS, Azure, and GCP.

What is Kubernetes, and why should you care?

Kubernetes is powerful because it is available everywhere (okay, almost everywhere). You can deploy it on all of the public cloud providers, and you can install it within your data centers. You can run a mini version called Minikube on your laptops too.

You can use the same Command Line Interface (CLI) called kubectl to develop using your local Kubernetes cluster and then deploy to a Kubernetes cluster running in the cloud when you are ready.

Image for post
Image for post
Kubernetes Local Environment

Development Environment Setup

Step 1 — Install a hypervisor — VirtualBox

A hypervisor is a software that allows you to create and run virtual machines on your local box. We are using VirtualBox but you can use others, like HyperKit and VMware Fusion on macOS.

Our instructions are for macOS but you can find equivalent Windows and Linux commands too.

Download and install VirtualBox from here.

Step 2 — Install Minikube

For macOS, the easiest way to install Minikube is by using brew. If you do not have brew installed then you can install as follows -

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

To install Minikube the command is as simple as -

brew install minikube

Start Minikube —

minikube start --vm-driver=virtualbox

Step 3 — Install kubectl

With brew, installing kubectl is a breeze too -

brew install kubectl

Run Hello World Node.js Server

THAT’s IT. Now, let’s run Hello World using Node.js on your machine -

Pull this image from Google Registry, to create a deployment (more about this later) —

kubectl create deployment hello-node --image=gcr.io/hello-minikube-zero-install/hello-node

Expose the service on the pod (to be explained in future tutorials) that was created.

kubectl expose deployment hello-node --type=LoadBalancer --port=8080

Now, your service is up and running. You can browse your glorious website with this simple command that opens your default browser and take you to the webserver running locally on your machine —

minikube service hello-node

With this, you see the prized and desired “Hello World!” page, which is running on Node server all within your local machine.

Image for post
Image for post
Nirvana Hello World! Page delivered from your local box.

Recap and Next Steps

  • If you followed these simple steps, you now have a working Kubernetes cluster on your laptop or desktop.
  • Subsequent tutorials walk you through different concepts that you need to understand for working with containers to build your applications and websites.
  • Please follow Product Studio to keep building this quick, free, scalable, and portable stack and let us know if you have any feedback.

Product Studio

All That A Full-Stack Founder Needs To Build Software…

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store