Page Content

Tutorials

Setting up a Kubernetes cluster locally with minikube

Minikube is the perfect tool for setting up a local, single-node Kubernetes cluster on a PC for testing and education. It works by starting a virtual machine (VM) on your desktop or laptop that has Docker and Kubernetes enabled.

A popular method for learning and developing for Kubernetes without the expense or complexity of a cloud provider is to set up a Kubernetes cluster locally using minikube. Using a local virtual machine (VM) or container on your PC, Minikube starts a single-node cluster.

You can also read What is the DaemonSet in Kubernetes? & It’s Use Cases

Prerequisites

Make sure the following hardware and software requirements are met by your computer before starting:

  • Hardware: Hardware includes a minimum of two CPUs, 20GB of free storage space, 2GB of free memory, and an internet connection.
  • Virtualization: Installing a container or virtual machine management is required. Typical choices are KVM (for Linux), Docker, VirtualBox, and Hyper-V (for Windows).
  • kubectl: To communicate with the cluster after it is operational, you require the official Kubernetes command-line tool, kubectl.

Installation

The installation process varies depending on your operating system:

  • Linux: You can download the binary using curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 and install it to your path with sudo install minikube-linux-amd64 /usr/local/bin/minikube.
  • macOS: The simplest method is using Homebrew with the command brew install minikube.
  • Windows: You can download the .exe installer or use a package manager like Chocolatey (choco install minikube) or Windows Package Manager (winget install minikube).

You can also read What is Kubernetes Cloud Controller Manager?

Starting the Cluster

With just one command after installation, you may establish and launch the cluster:

minikube start

Minikube will automatically choose a driver based on your surroundings. If necessary, you can explicitly specify a driver (e.g., --driver=docker or --driver=virtualbox). This command sets up your local kubectl to connect to the new cluster and provision the virtual machine or container.

Verification and Management

The cluster can be managed using these fundamental commands once it has been started:

  • Verify Health: Verify that every component is “Running” or “Configured” by running minikube status.
  • Access Dashboard: Launch minikube dashboard to see your cluster resources in a web-based graphical user interface.
  • Manage Addons: You may use the minikube addons list to show the built-in features that are available and use minikube addons enable to enable them (such as the metrics-server or ingress).

You can also read What is a Kubernetes ReplicaSet & Working with ReplicaSets

Cleaning Up

You can oversee the cluster’s lifespan once you’re done:

  • Stop: The cluster state is saved for further usage when the virtual machine is shut down by minikube stop.
  • Delete: minikube delete eliminates the local cluster and all related data.

Note: Minikube does not offer the high availability or reliability needed for a production setting; it is primarily meant for local development and testing.

Core Commands

After installing the tools, you can use these main commands to administer the cluster:

  • minikube start: This command establishes a local virtual machine (VM), sets up Kubernetes, and sets your local kubectl to point to this new cluster automatically.
  • minikube status: Verify your local cluster’s availability and overall health.
  • minikube dashboard: The minikube dashboard allows you to view your cluster resources by opening a web-based graphical user interface in your browser.
  • minikube stop: Closes the virtual machine (VM) but keeps the cluster state for when it is restarted.
  • minikube delete: Eliminates the virtual machine (VM) and all related cluster information.

Accessing Services

Minikube operates within a virtual machine (VM), hence services are not instantly reachable over localhost.

  • To get the URL for an exposed service, use: minikube service <service-name> --url.
  • If you are using services of type LoadBalancer, you must run minikube tunnel in a separate terminal window to assign an external IP address to the service.

Limitations

Minikube is a great learning tool, however it is only meant for local development. Because it is a single-node system, it lacks the high availability and dependability of a distributed production cluster, and certain cloud-specific capabilities (such managed storage) might only function to a limited extent.

You can also read What is Kube-Proxy in Kubernetes and it’s Lifecycle

Thota Nithya
Thota Nithyahttps://govindhtech.com/
Hai, Iam Nithya. My role in Govindhtech involves contributing to the platform's mission of delivering the latest news and insights on emerging technologies such as artificial intelligence, cloud computing, computer hardware, and mobile devices.