Getting Started with Kubernetes
In this chapter, we’ll set up your local Kubernetes environment using Minikube and run your very first cluster. By the end, you’ll have a working K8s cluster on your laptop and will have deployed your first application.
Prerequisites
Before we begin, make sure you have:
- A computer with at least 8 GB RAM and 20 GB free disk space
- A hypervisor or container runtime installed (Docker is recommended)
- Admin/sudo access on your machine
What is Minikube?
Minikube is a tool that runs a single-node Kubernetes cluster on your local machine. It’s perfect for learning, development, and testing.
Minikube supports multiple drivers:
- Docker (recommended) — runs K8s inside a Docker container
- VirtualBox — runs K8s inside a VM
- HyperKit (macOS) — lightweight hypervisor
- Hyper-V (Windows) — built-in Windows hypervisor
Step 1 — Install kubectl
kubectl is the command-line tool for interacting with Kubernetes clusters. Install it first.
macOS
# Using Homebrew
brew install kubectl
# Verify installation
kubectl version --client
Linux (Ubuntu/Debian)
# Download the latest release
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
# Install
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
# Verify
kubectl version --client
Windows
# Using Chocolatey
choco install kubernetes-cli
# Verify
kubectl version --client
You should see output similar to:
Client Version: v1.31.0
Kustomize Version: v5.4.2
Step 2 — Install Minikube
macOS
# Using Homebrew
brew install minikube
Linux
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
Windows
# Using Chocolatey
choco install minikube
Verify the installation:
minikube version
Step 3 — Start Your First Cluster
Start a Kubernetes cluster with a single command:
minikube start
You should see output similar to:
😄 minikube v1.33.0 on Darwin (arm64)
✨ Automatically selected the docker driver
📌 Using Docker Desktop driver with root privileges
👍 Starting control plane node minikube in cluster minikube
🚜 Pulling base image ...
🔥 Creating docker container (CPE) ...
🐳 Preparing Kubernetes v1.30.0 on Docker 26.0.1 ...
▪ Generating certificates and keys ...
▪ Booting up control plane ...
▪ Configuring RBAC rules ...
🔗 Configuring bridge CNI (Container Networking Interface) ...
🔎 Verifying Kubernetes components...
▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🌟 Enabled addons: default-storageclass, storage-provisioner
🏄 Done! kubectl is now configured to use "minikube" cluster
Congratulations! You now have a running Kubernetes cluster.
Step 4 — Verify the Cluster
Run these commands to check your cluster status:
# Check cluster info
kubectl cluster-info
# Check nodes
kubectl get nodes
# Check all system pods
kubectl get pods -n kube-system
Expected output for kubectl get nodes:
NAME STATUS ROLES AGE VERSION
minikube Ready control-plane 60s v1.30.0
Step 5 — Deploy Your First Application
Let’s deploy a simple nginx web server to your cluster:
# Create a deployment
kubectl create deployment hello-k8s --image=nginx
# Check the deployment
kubectl get deployments
# Check the pod
kubectl get pods
You should see:
NAME READY STATUS RESTARTS AGE
hello-k8s-6d4f7b8c9-x2wlp 1/1 Running 0 30s
Now expose it as a service so you can access it:
# Expose the deployment as a service
kubectl expose deployment hello-k8s --type=NodePort --port=80
# Get the URL
minikube service hello-k8s --url
Open the URL in your browser — you should see the nginx welcome page. You just deployed your first application on Kubernetes!
Step 6 — Explore the Dashboard
Minikube comes with the Kubernetes Dashboard built-in:
minikube dashboard
This opens a web-based UI where you can visually explore your cluster — Pods, Deployments, Services, and more.
Step 7 — Clean Up
When you’re done experimenting:
# Delete the service and deployment
kubectl delete service hello-k8s
kubectl delete deployment hello-k8s
# Stop the cluster (preserves state)
minikube stop
# Delete the cluster entirely
minikube delete
Useful Minikube Commands
| Command | Description |
|---|---|
minikube start |
Start the cluster |
minikube stop |
Stop the cluster (preserves state) |
minikube delete |
Delete the cluster |
minikube status |
Check cluster status |
minikube dashboard |
Open the K8s dashboard |
minikube ssh |
SSH into the Minikube node |
minikube addons list |
List available addons |
minikube addons enable <name> |
Enable an addon (e.g., metrics-server) |
Useful kubectl Commands
| Command | Description |
|---|---|
kubectl get nodes |
List all nodes |
kubectl get pods |
List pods in current namespace |
kubectl get pods -A |
List pods in all namespaces |
kubectl get services |
List services |
kubectl describe pod <name> |
Detailed info about a pod |
kubectl logs <pod-name> |
View pod logs |
kubectl exec -it <pod> -- /bin/sh |
Open a shell inside a pod |
Summary
In this chapter, you:
- ✅ Installed kubectl and Minikube
- ✅ Started your first Kubernetes cluster
- ✅ Deployed an nginx application
- ✅ Exposed it as a Service and accessed it in the browser
- ✅ Explored the Kubernetes Dashboard
What’s Next?
Now that you have a working environment, it’s time to understand how Kubernetes works under the hood. In the next chapter, we’ll explore the Kubernetes Architecture — the control plane, worker nodes, and the components that make it all work.
Next: Kubernetes Architecture →
public class Car {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
Output:
Hello World