0
0
Kubernetesdevops~5 mins

Setting up a local cluster (minikube, kind) in Kubernetes - Step-by-Step CLI Walkthrough

Choose your learning style9 modes available
Introduction
Sometimes you want to try Kubernetes on your own computer without needing a big cloud setup. Local clusters let you run Kubernetes right on your laptop to learn and test apps easily.
When you want to learn Kubernetes basics without using cloud resources
When you need to test your app in a Kubernetes environment before deploying to production
When you want to try out Kubernetes features quickly without waiting for cloud setup
When you want to develop and debug Kubernetes apps locally
When you want to practice Kubernetes commands and configurations safely
Commands
This command starts a local Kubernetes cluster using Minikube on your computer. It sets up all necessary components so you can run Kubernetes commands locally.
Terminal
minikube start
Expected OutputExpected
šŸ˜„ minikube v1.30.1 on Ubuntu 22.04 ✨ Using the docker driver based on user configuration šŸ‘ Starting control plane node minikube in cluster minikube 🐳 Preparing Kubernetes v1.27.3 on Docker 24.0.5 🚜 Pulling images ... šŸš€ Launching Kubernetes ... āŒ› Waiting for: apiserver šŸ„ Done! kubectl is now configured to use "minikube"
→
--driver - Specify which virtualization driver to use (docker, virtualbox, etc.)
This command checks if the local Kubernetes cluster is running by listing the nodes. You should see one node named 'minikube' ready.
Terminal
kubectl get nodes
Expected OutputExpected
NAME STATUS ROLES AGE VERSION minikube Ready control-plane 1m v1.27.3
This command creates a local Kubernetes cluster named 'example-cluster' using Kind, which runs Kubernetes inside Docker containers.
Terminal
kind create cluster --name example-cluster
Expected OutputExpected
Creating cluster "example-cluster" ... āœ“ Ensuring node image (kindest/node:v1.27.3) šŸ–¼ āœ“ Preparing nodes šŸ“¦ āœ“ Writing configuration šŸ“œ āœ“ Starting control-plane šŸ•¹ļø āœ“ Installing CNI šŸ”Œ āœ“ Installing StorageClass šŸ’¾ Cluster creation complete. You can now use 'kubectl' to interact with your cluster.
→
--name - Set a custom name for the Kind cluster
This command shows information about the Kind cluster to confirm it is running and accessible.
Terminal
kubectl cluster-info --context kind-example-cluster
Expected OutputExpected
Kubernetes control plane is running at https://127.0.0.1:6443 CoreDNS is running at https://127.0.0.1:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
→
--context - Specify the Kubernetes context to use for the command
Key Concept

If you remember nothing else from this pattern, remember: local Kubernetes clusters let you safely learn and test Kubernetes on your own computer without cloud setup.

Common Mistakes
Not installing a virtualization driver like Docker or VirtualBox before starting Minikube
Minikube needs a driver to create virtual machines or containers; without it, the cluster won't start.
Install Docker or VirtualBox and ensure it runs before running 'minikube start'.
Running 'kubectl' commands before the cluster is fully ready
The cluster components may not be ready yet, causing errors or empty outputs.
Wait for the 'minikube start' or 'kind create cluster' command to finish completely before using kubectl.
Using the wrong kubectl context after creating multiple clusters
kubectl commands may target the wrong cluster, causing confusion or errors.
Use 'kubectl config get-contexts' to check and 'kubectl config use-context' to switch to the correct cluster.
Summary
Use 'minikube start' or 'kind create cluster' to set up a local Kubernetes cluster on your computer.
Verify the cluster is running with 'kubectl get nodes' or 'kubectl cluster-info'.
Make sure your virtualization driver is installed and kubectl context is correct before running commands.