Kubernetes Basics: Your First Cluster and Pod
You will create a local Kubernetes cluster, learn the core kubectl workflow, and run your first deployment. By the end you will understand how the control plane keeps your desired state running.
Learning Objectives
- Spin up a local cluster with kind or minikube.
- Use kubectl to create and inspect workloads.
- Run a self-healing deployment.
- Time: ~3 hours · Difficulty: Intermediate · Prereqs: Docker and kubectl installed.
Architecture Overview
graph LR
K[kubectl] -->|apply| API[API Server]
API --> ETCD[(etcd desired state)]
API --> Sch[Scheduler]
Sch --> Node[Worker Node]
Node --> Pod[Pod]
CM[Controller Manager] -->|reconcile| API
Environment Setup
You will need: Docker, kubectl, and kind (or minikube).
Before you begin: confirm kubectl is installed with kubectl version --client.
Step-by-Step Execution
01
Create a local cluster
kind create cluster --name labBoots a single-node Kubernetes cluster in Docker.
02
Run a deployment
A Deployment declares desired replicas; the controller keeps that many pods running.
kubectl create deployment web --image=nginx:stable --replicas=203
Inspect the cluster
$ kubectl get pods -o wide
NAME READY STATUS NODE
web-6f...-a1b2 1/1 Running lab-control-plane
web-6f...-c3d4 1/1 Running lab-control-plane
Progress So Far
graph LR
A[01 Create cluster] -->|done| B[02 Deployment]
B -->|done| C[03 Inspect]
C -->|next| V[Self-heal test]
style A fill:#1a4a1a,stroke:#00ff00,color:#fff
style B fill:#1a4a1a,stroke:#00ff00,color:#fff
style C fill:#1a4a1a,stroke:#00ff00,color:#fff
style V fill:#1a1a2e,stroke:#00d4ff,color:#e0e0e0
Testing & Validation
kubectl delete pod -l app=web --field-selector status.phase=Running --grace-period=0 | head -1; kubectl get deploy webAfter deleting a pod, the deployment should report the desired replica count again within seconds, proving self-healing.
Troubleshooting
- kubectl cannot connect: kind writes a kubeconfig context; confirm with
kubectl config current-context. - Pods Pending: the node may lack resources; check
kubectl describe pod. - ImagePullBackOff: the image name or tag is wrong; verify it pulls with docker.
Extension Ideas
- Expose the deployment in Pods & Deployments.
- Add networking and Services in Kubernetes Networking.
- Move to managed Kubernetes in Azure Kubernetes Service.
Key Results
- Created a working local Kubernetes cluster.
- Ran a 2-replica deployment via kubectl.
- Observed control-plane reconciliation of desired state.
- Proved self-healing by deleting and recovering a pod.