How to Run Kubernetes Cluster locally (minikube)? K8s – Part: 6

0
127
views
How to Run Kubernetes Cluster locally (minikube)? K8s – Part: 6

How to Run Kubernets Cluster locally (minikube)?

Do you know minikube? or how to run minikube? Let it be! First of all, know minikube!

What is minikube?

Minikube is in existence because it was required to run Kubernetes as a single node cluster and Minikube do it as it is designed. Minikube runs a single Go binary (named localkube), which runs all the Kubernetes components. It can run a single-node Kubernetes cluster inside a VM for trying out Kubernetes or for development purpose. Minikube uses libmachine for provisioning VMs, and kubeadm to provision a kubernetes cluster.

Features:

  • Kuberenets features like DNS, Dashboards, CNI, NodePorts, ConfigMaps and Secrets etc are supported by minikube
  • Minikube supports rkt container engine along with Docker containers.
  • Possible to reuse the minikube’s built-in Docker daemon
  • Supports persistent volumes and host folder mounting.
  • Kubernetes environment configurable.

Requirements:

  • kubectl (Read Kubernetes Installation )
  • VirtualBox or KVM
  • VT-x/AMD-v virtualization must be enabled in BIOS
  • Internet connection on the first run




NOTE: If you use –vm-driver=none, be sure to specify a bridge network for docker. Otherwise, it might change between network restarts, causing loss of connectivity to your cluster.

Let’s Start

Step 1: Setup KVM2 driver

Setup KVM driver to communicate with Minikube as we are going to setup Minikube inside a VM. If you are using a bare metal then you may skip this but still, I would suggest going KVM driver installation.

Step2: Download Minikube

Now download the Minikube and set up this under /usr/local/bin

Step 3: Start Minkube

If you want to change the VM driver add the appropriate –vm-driver=xxx. We can start the minikube with the driver

Step 4: Setup Minikube Context

Now set the Minikube context. The context is what determines which cluster kubectl is interacting with. You can see all your available contexts in the ~/.kube/config file.

To further debug and diagnose cluster problems, use ‘kubectl cluster-info dump‘.
With this last command, we have set up Minikube cluster on our system. And ready to use.
For this article, we will deploy a sample application and try to figure out some basic commands to know more about Kubernetes cluster.




Lets Start

Step 1: Create and deploy a sample app.

We are going to use a hell Minikube using echoserver image on port 8080 and expose that as node port because it’s a single node cluster.

with these commands, we have created a deployment and exposed our service on port 8080.

Step 2: Get Pod Details and access Our App

Now we will check our pods status and try to access our services.

Now you may access your service by directly hitting curl command on your terminal like below

Or you may get the URL of your service and access it on a browser

Now access http://192.168.99.100:31349 in your browser

Step 3: Clean up

Now we are doing to clean up our deployment and stop Minikube. This can be done so easily by following commands.

Well, this brings ends to our Minikube introduction and a sample application deployment. In the next article, we will get to gather with some useful command for Minikube.

Kubernetes Series Links:

Understanding Kubernetes Concepts RHEL/CentOs K8s Part-1
Understanding Kubernetes Concepts RHEL/CentOs k8s: Part-2
How to Install Kubernetes on CentOS/RHEL k8s?: Part-3
How to Install Kubernetes on CentOS/RHEL k8s?: Part-4
How To Bring Up The Kubernetes Dashboard? K8s-Part: 5
How to Run Kubernetes Cluster locally (minikube)? K8s – Part: 6
How To Handle Minikube(Cheatsheet)-3? K8s – Part: 7
How To Handle Minikube(Cheatsheet)-3? K8s – Part: 8
How To Handle Minikube(Cheatsheet)-3? K8s – Part: 9