What is Kubernetes (k8s)?
Kubernetes (commonly known as k8s) is an open-source platform for automating the deployment, scaling, and management of containerized applications.
- Node: A physical or virtual machine where containers actually run.
- Master Node: Manages the entire cluster and controls container deployment, scaling, etc.
- Cluster: A collection of multiple nodes (master nodes and worker nodes) that serves as the management unit for Kubernetes.
Minikube
Minikube is a tool developed by SIG-Cluster-Lifecycle (a Kubernetes community group) that allows you to easily set up and run a single-node Kubernetes cluster in a local environment. It is ideal for trying out Kubernetes for development and testing purposes.
Minikube builds and runs a Kubernetes environment inside a local virtual machine (VM) or container, requiring a hypervisor (VMware Fusion, VirtualBox, Hyper-V, etc.) or container runtime (Docker, Podman, etc.). Minikube uses these drivers to automatically set up the host environment and deploy Kubernetes on top of it.
Note for M1 Macs: While hypervisor options were previously limited on M1 Macs, Docker Desktop now natively supports M1 Macs, and Minikube works smoothly using the Docker driver.
Installing Minikube
Install Minikube using Homebrew (for macOS).
brew install minikube
This command also installs kubectl, the command-line tool for operating Kubernetes clusters.
Building a Kubernetes Environment with Minikube
Running the minikube start command starts a Kubernetes cluster locally.
minikube start
The first startup may take some time as it downloads required images and sets up the cluster.
Switching Contexts
When using multiple Kubernetes clusters, you need to switch the Context to specify which cluster kubectl should operate on. When Minikube is started, the Minikube cluster Context is automatically set.
kubectl config use-context minikube
Verifying Nodes
Check the node status to confirm the cluster is running properly.
kubectl get nodes
If a node named minikube is in Ready status, the cluster is operating normally.
Deleting the Minikube Cluster
To stop the Minikube cluster and delete its related resources, use the minikube delete command.
minikube delete
This cleans up the virtual machines, containers, and related files created by Minikube.
References
- Masaya Aoyama, “Kubernetes Complete Guide 2nd Edition, impress top gear series”, Impress (2021)
- Minikube Official Documentation