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.
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 (K8S) is an open-source container orchestrator that provides tools to deploy, run, and manage your containers and container images.
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.
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.
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.