Setting Up Your Environment

Before we dive into Kubernetes, let’s set up your local development environment. We’ll install the necessary tools and create your first cluster.

Installing kubectl

kubectl is the command-line tool for interacting with Kubernetes clusters.

macOS

Terminal window
brew install kubectl

Linux

Terminal window
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

Windows

Terminal window
choco install kubernetes-cli

Verify the installation:

Terminal window
kubectl version --client

Installing Minikube

Minikube runs a single-node Kubernetes cluster locally, perfect for development and learning.

macOS

Terminal window
brew install minikube

Linux

Terminal window
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube

Windows

Terminal window
choco install minikube

Starting Your First Cluster

Start Minikube with the following command:

Terminal window
minikube start

This process will:

  • Download the Kubernetes components
  • Create a virtual machine
  • Configure kubectl to connect to your new cluster

Check the cluster status:

Terminal window
kubectl cluster-info
kubectl get nodes

You should see output indicating your cluster is running:

NAME STATUS ROLES AGE VERSION
minikube Ready control-plane 1m v1.28.0

Verifying Your Setup

Let’s verify everything is working correctly by deploying a simple application:

Terminal window
kubectl create deployment hello-minikube --image=kicbase/echo-server:1.0
kubectl expose deployment hello-minikube --type=NodePort --port=8080

Access the application:

Terminal window
minikube service hello-minikube

This will open your browser with the running application.

Useful Minikube Commands

Here are some helpful commands for managing your Minikube cluster:

Terminal window
# Stop the cluster
minikube stop
# Delete the cluster
minikube delete
# View Minikube dashboard
minikube dashboard
# SSH into the Minikube VM
minikube ssh

Alternative Options

While Minikube is great for learning, you have other options:

  • kind (Kubernetes in Docker) - Runs Kubernetes in Docker containers
  • k3s - Lightweight Kubernetes distribution
  • Docker Desktop - Includes Kubernetes support
  • Cloud providers - GKE, EKS, AKS for production environments

Next Steps

Now that your environment is set up, let’s explore Kubernetes core concepts in the next section.