Installing Kubernetes with Minikube

Tutorial 3 of 5

1. Introduction

Goal

The goal of this tutorial is to guide you through the process of installing Kubernetes on your local machine using Minikube.

Learning Objectives

By the end of this tutorial, you will be able to set up and run a Kubernetes cluster on your local machine using Minikube.

Prerequisites

  • Basic knowledge of Docker and containerization
  • A local machine with Docker installed

2. Step-by-Step Guide

Installing Minikube

Before we can begin, ensure that you have installed VirtualBox or Hyper-V on your machine. These are hypervisors that Minikube will use to create a virtual machine where your Kubernetes cluster will run.

  1. Download and install Minikube from the official Github repository.
  2. Once installed, you can verify the installation by running minikube version in your terminal.

Starting Minikube

  1. To start a local Kubernetes cluster, run minikube start.
  2. To interact with your cluster, you'll use kubectl, the Kubernetes command-line tool. If you don't have it installed, Minikube can install it for you with minikube kubectl -- get pods -A.
  3. To stop your cluster, run minikube stop.

3. Code Examples

Here are some practical examples:

Example 1: Start Minikube

# Start Minikube
minikube start

This command starts your Minikube cluster. After running this, your terminal should output that the Kubernetes cluster is running.

Example 2: Check Kubernetes version

# Check Kubernetes version
minikube kubectl -- version

This command will display the version of Kubernetes that is running on your Minikube cluster.

Example 3: Stop Minikube

# Stop Minikube
minikube stop

This command will stop your Minikube cluster. You should see a message that your cluster has stopped.

4. Summary

In this tutorial, you learned how to install Minikube, start a local Kubernetes cluster, and interact with it using kubectl. Your next steps could include exploring more kubectl commands or learning how to deploy applications on your Kubernetes cluster.

For additional resources, check out the official Kubernetes documentation.

5. Practice Exercises

Exercise 1: Install Minikube on your machine and start a local Kubernetes cluster.

Solution: Follow the step-by-step guide provided above.

Exercise 2: Use kubectl to get a list of nodes in your cluster.

Solution:

# Get a list of nodes
minikube kubectl -- get nodes

This command will output a list of nodes in your cluster. Since Minikube runs a single-node cluster, you should see one node listed.

Exercise 3: Stop your Minikube cluster and then start it again. Check to make sure that your cluster is running.

Solution:

# Stop Minikube
minikube stop

# Start Minikube
minikube start

# Check if cluster is running
minikube status

After running these commands, your terminal should output that your cluster is running.

For further practice, explore other kubectl commands and try deploying a simple application on your cluster.