Minikube is an excellent open-source tool that allows developers, enthusiasts, and DevOps engineers to get their hands on a fully-functioning Kubernetes cluster without the complexities or time involved in spinning up an entire K8s cluster. In this guide, we’ll walk through installing Minikube on Ubuntu 22.04, Ubuntu 20.04, and 18.04.
What is Minikube?
Before diving into the installation and interaction with Minikube, let’s look at the Minikube Kubernetes cluster solution. Minikube is an open-source solution enabling you to spin up a single-node Kubernetes cluster locally on your computer. If you have Docker installed, Minikube will run the node inside a container.
You can also run Minikube inside a virtual machine (VM) using a hypervisor. Developers can use it to learn, test, and develop applications using Kubernetes without setting up a full-scale, multi-node cluster. This is the primary objective of Minikube – to simplify the process of getting started with Kubernetes.
It makes K8s accessible to users who may not have access to extensive resources or a dedicated Kubernetes environment. Using a local cluster, Minikube enables users to focus on learning Kubernetes concepts and developing applications without the complexity of managing a full-scale production cluster or the challenges of provisioning one to get started.
Prerequisites for Installing Minikube
Before diving into the installation process, ensure that your Ubuntu system meets the following requirements:
- A compatible version of Ubuntu (22.04, 20.04, or 18.04)
- Hardware virtualization support enabled in the BIOS
- At least 2GB of free memory and 20GB of free disk space
- Root privileges for installation
Installing Dependencies
To install Minikube on Ubuntu, we first need to install some dependencies: Docker and Kubectl. First, let’s install Docker.
Installing Docker Engine
Docker is a platform that allows developers to automate the deployment and management of applications within containers. To install Docker on your Ubuntu system, follow these steps:
- Update the package list:
sudo apt-get update
- Install Docker CE (Community Edition) following the official guidance from Docker here: Install Docker Engine on Ubuntu | Docker Documentation.
Below is a summary of the commands to install Docker in Ubuntu from the official documentation.sudo apt-get update sudo apt-get install \ ca-certificates \ curl \ gnupg sudo install -m 0755 -d /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg sudo chmod a+r /etc/apt/keyrings/docker.gpg echo \ "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
After installing Docker, verify the installation by checking the Docker version:
docker --version
Installing Kubectl
Kubectl is a command-line tool that allows you to interact with a Kubernetes cluster. To install Kubectl, run the following commands:
- Download the latest Kubectl binary:
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
- Make the binary executable:
chmod +x ./kubectl
- Move the binary to your PATH:
sudo mv ./kubectl /usr/local/bin/kubectl
Verify the Kubectl installation by checking its version:
kubectl version --client
Installing Minikube
With Docker and Kubectl installed, we can now proceed to install Minikube. Follow the steps below:
- Download the latest Minikube binary:
wget https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
- Make the binary executable:
chmod +x minikube-linux-amd64
- Move the binary to your PATH:
sudo mv minikube-linux-amd64 /usr/local/bin/minikube
Verify the Minikube installation by checking its version:
minikube version
Start Minikube
With Minikube installed, it’s time to start the single-node Kubernetes cluster. The single node cluster will be the control plane node Minikube configuration that doubles as a worker. To do this, run the following command:
minikube start
By default, Minikube uses the Docker driver, which means it will create a Docker container for the Kubernetes control plane. If you prefer to use another virtual machine manager, such as VirtualBox, you can specify it using the –driver flag:
minikube start --driver=virtualbox
Wait for the command to complete. Once finished, you should see a message indicating that the Kubernetes cluster is running. Remember that you must install Virtualbox, as this is not done automatically as part of the Minikube setup.
Interacting with Your Minikube Cluster
Once you’ve successfully started your Minikube cluster, the next step is communicating with it using the Kubectl command-line tool. Kubectl enables you to manage and monitor your cluster efficiently.
Checking the Cluster Status
To view the current status of your Minikube cluster, execute the following command:
minikube status
This command will provide you with information about the Minikube VM, the Kubernetes control plane host, and other relevant details.
Inspecting Nodes in the Cluster
To see the nodes present in your cluster, use this command:
kubectl get nodes
As a single-node Kubernetes cluster, Minikube will display one node with the status “Ready,” signifying that the Kubernetes control plane is functioning properly.
To see the Minikube contexts set, you can use the command:
kubectl config get-contexts
Accessing the Kubernetes Dashboard
The Kubernetes Dashboard offers a web-based user interface that delivers an overview of your cluster’s status and allows you to manage Kubernetes resources effectively. To access the dashboard, follow these steps:
- Enable the dashboard addon:
minikube addons enable dashboard
- Launch the dashboard and obtain its URL:
minikube dashboard --url
The command will return a URL that you can use to access the dashboard from your browser.
Working with Minikube Addons
Minikube addons are features and tools that can be enabled or disabled to tailor your cluster according to your preferences. To see the available add-ons, run:
minikube addons list
To enable or disable an addon, use the minikube addons enable or minikube addons disable commands, followed by the addon name.
Example: Enabling the Metrics Server Addon
The Metrics Server addon provides resource usage data for your Kubernetes cluster. To enable it, run:
minikube addons enable metrics-server
Stopping and Removing Your Minikube Cluster
When you no longer need your Minikube cluster, you can stop and delete it using the following commands:
- Stop the Minikube cluster:
minikube stop
- Remove the Minikube cluster:
minikube delete
Minikube FAQs
This section will address some frequently asked questions about Minikube and its usage.
Can I run multiple nodes with Minikube?
Minikube is designed to run a single-node Kubernetes cluster for learning, development, and testing purposes. While it doesn’t natively support multiple nodes, you can use tools like Kind or K3s to create multi-node clusters on your local machine. However, for production environments, it’s recommended to use a full-scale, managed Kubernetes service, such as Google Kubernetes Engine (GKE), Amazon Elastic Kubernetes Service (EKS), or Azure Kubernetes Service (AKS).
How do I switch between different Kubernetes versions in Minikube?
Minikube allows you to run different Kubernetes versions by specifying the version during the minikube start command. To run a specific version, use the –kubernetes-version flag followed by the desired version number, like this:
minikube start --kubernetes-version v1.22.0
The list of supported Kubernetes versions is on the Minikube GitHub releases page.
How do I choose between the Docker driver and the VirtualBox hypervisor for Minikube?
Minikube supports multiple drivers, including the Docker driver and the VirtualBox hypervisor. The choice depends on your requirements and system resources. The Docker driver uses Docker containers to run the Minikube cluster, which can be more efficient in terms of resource usage. The VirtualBox hypervisor creates a separate virtual machine for your Minikube cluster, which may provide better isolation. To choose a specific driver, use the –driver flag during the minikube start command, like this:
minikube start --driver=docker
or
minikube start --driver=virtualbox
How do I access services running inside my Minikube cluster?
To access services running within your Minikube cluster, you can use the minikube service command followed by the service name. This command will open a browser window or provide a URL pointing to the service. For example, to access a service named my-service, run:
minikube service my-service
This command will either open the service in your default web browser or display a URL that you can use to access the service manually.
Wrapping Up
Minikube is an excellent Kubernetes tool for development and learning. If you want a quick and easy way to get your hands on a Kubernetes cluster, Minikube is a great option. With Minikube, you can experiment with the Kubernetes Dashboard, APIs, and many other great add-ons. In addition, you can experiment with Kubernetes and develop applications in a local environment, eliminating the need for a complex, full-scale cluster.