Minikube and kubectl
Understanding Minikube and Kubernetes Cluster Architecture
Kubernetes Cluster in Production Environments
Typically involves multiple nodes:
At least two master nodes
Multiple worker nodes
Each node (virtual or physical) runs independently and fulfills specific responsibilities
Challenges with Local Testing
Full production cluster setup is resource-intensive:
Requires significant CPU, memory, and network resources
Infeasible for quick, local testing
Minikube – Local Kubernetes Solution
A one-node Kubernetes cluster suitable for local development
Combines master and worker processes on a single node
Utilizes a virtual machine (VM) via hypervisor (e.g., VirtualBox, HyperKit)
Comes with:
Docker runtime pre-installed to run containers
Runs within a virtualized environment (e.g., VirtualBox, HyperKit)
Designed for:
Local development
Quick testing of applications or components
Example:
Instead of deploying a complex multi-node setup, a developer can use Minikube to simulate a Kubernetes cluster for testing on a laptop.
kubectl – The Kubernetes Command-Line Tool
Purpose and Functionality
CLI tool used to interact with Kubernetes clusters
Supports actions like creating pods, services, and deleting resources
Communicates with Kubernetes API server (part of the master processes)
API Server – Central Entry Point
Accepts requests from:
kubectl (CLI)
Kubernetes Dashboard (UI)
Direct API calls
kubectl is the most powerful and comprehensive interface among the three
Execution Flow:
kubectl
sends requests to the API serverAPI server coordinates with worker processes to:
Execute commands
Manage containers, services, deployments, etc.
Compatibility:
Not limited to Minikube
Works with cloud-based and hybrid clusters as well
Installation Requirements and Process
General Requirements
Minikube Requires a Hypervisor
To run VM locally
Options include:
VirtualBox
HyperKit (used in the example)
Operating System Support:
Works across platforms
Installation commands vary per OS (Mac, Windows, Linux)
Installation on macOS (Example)
Step 1: Install Hypervisor
Example used: HyperKit
Required to create VM for Minikube
Step 2: Install Minikube
Also installs kubectl as a dependency
No need to install
kubectl
separately
Installer pulls down:
Kubernetes CLI (i.e.,
kubectl
)Any additional dependencies
Validation of Installation
Run
kubectl
to confirm CLI is operationalDisplays command list
Run
minikube
to confirm Minikube CLI is accessible
Starting and Managing a Minikube Cluster
Starting the Cluster
Command Example:
minikube start --vm-driver=hyperkit
-vm-driver
: Specifies the hypervisor to use (e.g., HyperKit)
Setup Highlights:
Downloads necessary resources if not cached
Starts a VM with both master and worker processes
Docker runtime is pre-installed inside the node VM
Works even if Docker is not installed on the host machine
Post-Setup Checks
Verify Cluster Status
Run:
kubectl get nodes
→ Shows node readinessminikube status
→ Confirms services (e.g., kubelet, container runtime) are running
Example output:
Node is ready
Role: master
Version Check
kubectl version
Displays client and server versions
Example: Kubernetes v1.17
Debugging and Troubleshooting Minikube
Deleting and Restarting the Cluster
To reset setup:
minikube delete
Starting in Debug Mode
For detailed logs and error tracking:
minikube start --vm-driver=hyperkit --alsologtostderr -v=7
-alsologtostderr
andv=7
: Enable verbose logging to consoleHelpful when:
Minikube fails to start
Dependencies or VM drivers fail