Install Minikube with Kubernetes in Windows and deploy a sample Spring boot application

Eresh Gorantla
FAUN — Developer Community 🐾
5 min readDec 16, 2019

--

This story focuses on how to install and deploy a sample spring boot application in Minikube in Kubernetes run time.

What is Kubernetes?

Kubernetes is a portable, extensible, open-source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation. It has a large, rapidly growing ecosystem. Kubernetes services, support, and tools are widely available.

Kubernetes (K8s) is an open-source system for automating deployment, scaling, and management of containerized applications.

What is Minikube?

Minikube is a tool that makes it easy to run Kubernetes locally. Minikube runs a single-node Kubernetes cluster inside a Virtual Machine (VM) on your laptop for users looking to try out Kubernetes or develop with it day-to-day. Playing Kubernetes concepts is easy in local machine. Minikube facilitates us to play with Kubernetes locally.

Install Kubernetes

Please visit a page here. It has clear documentation of Minikube installation and Kubernetes instance in Minikube.

Prerequisite:

  • Should enable Virtual VM option in windows boot.
  • Install Oracle Virtual Box VM. https://www.virtualbox.org/wiki/Downloads
  • Minikube will not work on Hyper-V. If you have installed docker in your system you might have installed Hyper-V. Please disable it by navigating Control Panel → System And Security → Programs → Under Programs And Features → Turn Windows feature on and off. Click this and uncheck Hyper-V.

Installation:

Follow steps from the link

Minikube :- https://kubernetes.io/docs/tasks/tools/install-minikube/

Kubernetes :- https://kubernetes.io/docs/tasks/tools/install-kubectl/

Note:-

At any given point of time, minikube and kubectl fails don’t restart command instead run minikube delete and re-run the scripts.

If minikube delete also fails to go to the directory where minikube is installed in your system delete the complete physical location and reinstall minikube.

Please see the video below. Steps to start Kubernetes in Minikube for Windows operating system.

Here are the steps

  • Use command minikube start. Typically, it takes 3–5 mins.
  • Then to set vm-driver as virtual box minikube config set vm-driver virtualbox. This step is optional.
  • Use the context of minikube
    kubectl config use-context minikube
  • See cluster-info of minikube in your local machine.
    kubectl cluster-info
  • Next, open the dashboard of minikube which navigates to the Kubernetes dashboard.
    minikube dashboard
Screenshot of the commands

After the final command dashboard, it opens a browser and the following screen is seen.

Kubernetes hosted in local Minikube

Deploy a Spring Boot application in Kubernetes

A simple spring boot application with one Rest API which returns a static data. Our main intention is to test application deployment in local Kubernetes set up in minikube.

Please find the source code here.

This is Rest API just returns an object which has id, name, place, and value.

Check out the git repository.

Please check console log of deployment steps

Console Minikube Logs
  • Build a Spring boot application using maven commands.
  • Minikube has Linux command streams ie., ssh terminal. We can log in to the ssh terminal in minikube.

Note: In Minikube ssh, we can get access to only UserDocuments folder.

  • Give a docker build, from minikube ssh terminal.
Docker FIle
Console Log for Minikube SSH
  • Now create a deployment from the YAML file using fabric8.

Here the namespace is considered to be the “default”. We can create a namespace of our choice.

Deployment command

This will create a deployment in Kubernetes. Now we have to create pods ( Pods are the smallest deployable units of computing that can be created and managed in Kubernetes.).

  • Check deployments in Kubernetes as we created deployment using YAML script.
Deployments List
  • Execute services in Pods now and check status.

Now the application is deployed in service you can viewport and URL like below.

Please open the URL in a browser.

Open Rest API endpoint /home/data

API Response

To clean up deployments

kubectl delete service minikube-sample
kubectl delete deployment minikube-sample

If this post was helpful, please click the clap 👏 button below a few times to show your support for the author! ⬇

--

--

Experience in Open source stack, microservices, event-driven, analytics. Loves Cricket, cooking, movies and travelling.