So I have been spending bunch of time trying to learn more around using Kubernetes. For the lack of wanting to run in production on one of the big clouds I decided I’d finally start taking a wack at minikube.

minikube is basically setting up a VM you can run locally to test using Kubernetes. You’ll get a ready to deploy to cluster on your workstation without having to do all the work associated with creating a full cluster. It’s going to give you some baseline ability to work with what you’d do in production right on your local computer. In this case I am just using my Mac.

Installing minikube and kubectl — the most important packages you need was a simple brew install. For your local OS or more detail, check out the Kubernetes docs on installing these packages.

After installing, starting minikube is pretty dang easy, like this easy…

Starting minikube

After I start minikube I can use the Kubernetes command line tool, kubectl for starting my pods and service.

So first I have a pretty basic Node.js “todo” app I am working with. I will build my Docker image I will eventually deploy with minikube. You can get this Scotch.io “node-todo” right here.

I’ve got a pretty simply Dockerfile created for this app:

FROM node:boron RUN mkdir -p /usr/src/app

WORKDIR /usr/src/app COPY . /usr/src/app EXPOSE 8080 CMD [“npm”, “start”]

Set up my Docker environment:

bash-3.2$ eval $(minikube docker-env)

Create my image:

bash-3.2$ docker build -t node-todo:v1 .

Docker image of my Node.js webapp.

Now create a deployment of my app with kubectl:

bash-3.2$ kubectl run node-todo — image=node-todo:v1 — port=8080

deployment “node-todo” created

Looks like my app is deployed to my pod:

Now I will expose the deployment so I am able to access the app on the instance.

bash-3.2$ kubectl expose deployment node-todo — type=LoadBalancer

service “node-todo” exposed

I am only using single node for this deployment, but regardless I have added a loadbalancer so I can easily add more resources to scale up if needed.

Finally I can browse my minikube deployed app by using browse:

I went over to my browser and here we go…

My service for my app running on port 8080 is forwarded to 31284 when exposed to my local network.

When you’re done, terminating the VM is really easy with minikube:

This is my super duper bare minimum intro to loading a Docker image locally into your minikube workstation. Please read all the appropriate documentation for your own use. If you run into any issues with minikube or kubectl, please refer to the Kubernetes Documentation.