Running Kubernetes Locally Using Minikube

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Running Kubernetes locally using Minikube

(for Windows)
Introduction
What is Kubernetes?
Kubernetes is an open-source platform designed to automate deploying, scaling, and operating
application containers.

With Kubernetes, you are able to quickly and efficiently respond to customer demand:

 Deploy your applications quickly and predictably.


 Scale your applications on the fly.
 Roll out new features seamlessly.
 Limit hardware usage to required resources only.

What is Minikube?
Minikube is a tool that makes it easy to run Kubernetes locally. Minikube runs a single-node Kubernetes
cluster inside a VM on your laptop for users looking to try out Kubernetes or develop with it day-to-day.

Installing Minikube

Install a Hypervisor
If you do not already have a hypervisor installed, install one now.
 For OS X, install xhyve driver, VirtualBox, or VMware Fusion.
 For Linux, install VirtualBox or KVM.
 For Windows, install VirtualBox or Hyper-V.

Install kubectl
Refer this link - https://kubernetes.io/docs/tasks/tools/install-kubectl/

Install Minikube
1. Download the latest release from this link - https://github.com/kubernetes/minikube/releases
2. Rename the binary to minikube.exe and add it to your PATH.
3. Run minikube version to check if correctly installed
a. You can refer this link for other OS -
https://www.ibm.com/support/knowledgecenter/en/SS5PWC/minikube.html
4. Run ‘minikube start’
a. Starts a local kubernetes cluster
b. If you are doing it for the first time on a machine, it will take some time as it will
download Minikube ISO and other binaries, required to start Minikube.
c. Subsequent starts will use these cached images on your machine.

5. Run ‘minikube dashboard –url’ to get the Kubernetes dashboard url.

6. Open the Kubernetes dashboard URL in the browser and you can see the dashboard.
Deploying a Spring Boot Application Docker Image

1. For a start, we will use the spring boot docker example provided by spring starter projects.
a. git clone https://github.com/spring-guides/gs-spring-boot-docker.git
2. Back in the terminal, get the docker environment which comes with the Minikube internally to
build the docker image using command – minikube docker-env

3. Run the command given in the response to configure your shell, like eval $(Minikube docker-
env) in this example. This response can be different based on the shell you are using.
4. Now, you can run docker commands to see if docker env is setup.

5. Build your spring-boot-docker image. The spring starter example comes with the Dockerfile
which uses openjdk base image and exposes the service over the 8080 port.
6. Run docker images command to locate and see that your docker image has been built.

7. Push the docker image to Docker private registry or Docker hub using the repository name.
8. Create deployment for the docker image using command,
a. kubectl create deployment spring-boot-docker --image=repositoryname/spring-boot-
docker

9. Expose the deployment as a service using command,


a. kubectl expose deployment spring-boot-docker --port=8080 --type=LoadBalancer

10. Get the url of the service expose using command,


a. minikube service spring-boot-docker --url
11. Open up the url in the browser and you can see the expected output.

You might also like