Kubernetes

Minikube Tutorial Made Easy

Minikube Tutorial Made Easy
Developers and system admins interested to learn Kubernetes have heard of Minikube. Kubernetes is a complex container orchestration tool that can be overwhelming for beginners. Minikube was developed to help people learn Kubernetes and try out their ideas locally. In this tutorial, we will keep the information basic, so you can understand and run your first Kubernetes cluster on Minikube.

What is Minikube?

Minikube was developed to allow users to run Kubernetes locally. When you install and run Minikube on your computer, it runs a single-node Kubernetes cluster inside a virtual machine.

Why Minikube?

Minikube is intended for both new users and regular developers. Installing Kubernetes is time-consuming and resource-intensive. With Minikube, you get a smaller working version of a single-node Kubernetes cluster on your personal computer.

If you're a learner, it gives you the ability to play around and understand the basic concepts. Once you become regular practitioner you can still use Minikube to test out your ideas locally before you deploy it in your data center or server. It can work as your test environment.

What Can You Do With Minikube?

Minikube is great for learning Kubernetes and testing your concepts and ideas during development.

Prerequisite

Even though it's not necessary for this tutorial, a basic knowledge of containers like Docker is helpful to understand Minikube/Kubernetes.

Basic Definitions of Minikube/Kubernetes Concepts

To use Minikube, you need to understand the basic ideas discussed below. The definitions are not trying to explain the technology in depth. It's only giving you an understanding of the basic concepts of Kubernetes. In this discussion, Kubernetes and Minikube mean the same thing

To better understand how these concepts fit together in Kubernetes, watch this short video:

How to Install Minikube

Your hardware needs have virtualization enabled in your computer's BIOS. The good news is most modern machine already has this turned on.

Here are the steps to install Minkube on your machine:

Simple Example of Deploying on Minikube

Once you have everything installed, you can start Minikube with the following command:

$ minikube start
There is a newer version of minikube available (v0.28.0).  Download it here:
https://github.com/kubernetes/minikube/releases/tag/v0.28.0
To disable this notification, run the following:
minikube config set WantUpdateNotification false
Starting local Kubernetes v1.9.0 cluster…
Starting VM…
Getting VM IP address…
Moving files into cluster…
Setting up certs…
Connecting to cluster…
Setting up kubeconfig…
Starting cluster components…
Kubectl is now configured to use the cluster.
Loading cached images from config file.

On your first run, it will take time to fire up Minikube as it will build the VM for you. You can check you VirtualBox to see the virtual machine Minikube spins up:

Later when you restart Minikube it will be faster.

You can use the following command to check your Minikube status:

$ minikube status
minikube: Running
cluster: Running
kubectl: Correctly Configured: pointing to minikube-vm at 192.168.99.100

A great feature of Minikube is the dashboard. From the dashboard, you can see everything that is going on in Minikube. You can also control resources in your cluster from the dashboard. Use the following command to start up the dashboard in your default browser:

$ minikube dashboard
Opening kubernetes dashboard in default browser…

Here is how the dashboard should look:

Let's deploy an NGINX application on Minikube. Here are the steps:

1. Create a pod:

$ kubectl run mynginxapp --image=nginx:latest --port=80
deployment "mynginxapp" created

2. Create a service:

$ kubectl expose deployment mynginxapp --type=NodePort
service "mynginxapp" exposed

3. Check your pod and service status:

$ kubectl get pods
NAME                          READY     STATUS    RESTARTS   AGE
mynginxapp-6d64b788cc-j5crt   1/1       Running   0          4m

$ kubectl get services
NAME         TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)        AGE
kubernetes   ClusterIP   10.96.0.1             443/TCP        1h
mynginxapp   NodePort    10.97.47.26           80:30964/TCP   1m

You can see that the pod and the service running for mynginxapp.

4. Let's find at what address and port Minikube is running mynginxapp:

$ Minikube service mynginxapp --URL
http://192.168.99.100:30964

If you go to the returned URL (in this case it is http://192.168.99.100:30964) on your browser, you should see the NGINX service running.

5. Check the dashboard again:

$ Minikube dashboard
Opening kubernetes dashboard in default browser…

6. Delete the service and the pod and stop Minikube

$ kubectl delete service mynginxapp
service "mynginxapp" deleted
$ kubectl delete deployment mynginxapp
deployment "mynginxapp" deleted
$ Minikube stop
Stopping local Kubernetes cluster…
Machine stopped.

Summary of the Example

In this example, you first deployed an NGINX pod called mynginxapp. The NGINX image was downloaded from Docker Hub. Then you created a service to support the pod. You were able to see the service from the browser. At last, you deleted the pod and the service and then stopped Minikube.

More Detailed Minikube Example

Check out our Kubernetes: Getting Started article that has a more detailed Minikube example.

Quiz - Test Your Knowledge

  1. Can you explain the concept of containers, pods, and services?
  2. How do containers, pods, and services interact with each other?
  3. What is kubectl?
  4. How many Kubernetes clusters can you start on Minikube?
Further Study
  • https://kubernetes.io/docs/tutorials/hello-Minikube
  • https://kubernetes.io/docs/home
  • https://www.digitalocean.com/community/tutorials/an-introduction-to-kubernetes
Instalați cel mai recent joc de strategie OpenRA pe Ubuntu Linux
OpenRA este un motor de jocuri de strategie în timp real Libre / Free care recreează primele jocuri Westwood, cum ar fi clasicul Command & Conquer: Re...
Instalați cel mai recent Dolphin Emulator pentru Gamecube și Wii pe Linux
Emulatorul Dolphin vă permite să jucați jocurile alese de Gamecube și Wii pe computerele personale Linux (PC). Fiind un emulator de joc liber disponi...
Cum se folosește GameConqueror Cheat Engine în Linux
Articolul acoperă un ghid despre utilizarea sistemului de înșelăciune GameConqueror în Linux. Mulți utilizatori care joacă jocuri pe Windows folosesc ...