3 Basics of Kubernetes

The master reference guide for Kubernetes basics โ€” architecture, core objects, workflows, and the command cheat sheet you'll actually use.

This is the Master Reference Guide. I have condensed everything we covered into a visual flow, theory recap, and a command cheat sheet.

Bookmark this. It is your roadmap from "Zero" to "Engineer."


๐Ÿ—๏ธ 1. The Big Picture: Architecture

Before typing commands, you must visualize where they go.

The Theory:


๐Ÿงฑ 2. The Core Objects (The "Lego Blocks")

Kubernetes uses specific objects to manage your software. Here is how they connect.

Object Analogy Responsibility
Deployment The Manager ๐Ÿ‘ท Ensures X copies of your app are always running. Restarts them if they crash.
Service The Phone # ๐Ÿ“ž Provides a stable IP address so others can find the Pods (which move around).
Ingress The Receptionist ๐Ÿ›Ž๏ธ Routes traffic from domain.com to the correct Service.
PVC External Drive ๐Ÿ’พ Persistent storage that survives when a Pod dies.
ConfigMap Sticky Note ๐Ÿ“ Non-sensitive settings (URLs, Colors).
Secret The Safe ๐Ÿ”’ Sensitive settings (Passwords, API Keys).

The "Magic Glue": Labels & Selectors

The Service finds the Pod using "stickers" (Labels).


๐Ÿ”„ 3. The "Zero to Hero" Workflow (The Flowchart)

This is the exact process we followed to deploy your custom Python app.

Step 1: Code & Build

  1. Write code (app.py).
  2. Write Dockerfile.
  3. Build Image: docker build -t my-app:v1 .

Step 2: The Minikube Bridge (Crucial for Local Dev)

Step 3: Deploy (The "Order")

Step 4: Access (The "Tunnel")


๐Ÿ“œ 4. The Ultimate Command Cheat Sheet

Copy-paste these into your notes. These are the commands you will use 90% of the time.

Setup & Cluster Management

minikube start                  # Start the cluster
minikube status                 # Check if it's running
minikube dashboard              # Open the GUI
minikube stop                   # Pause (save battery)
minikube delete                 # Nuke everything (start fresh)

Inspection (The "Get" Commands)

kubectl get nodes               # Check your servers
kubectl get pods                # Check your containers
kubectl get svc                 # Check your Services (IPs)
kubectl get deploy              # Check your Deployments
kubectl get ingress             # Check your URLs/Rules

Debugging (When Things Break)

kubectl describe pod <name>     # Detailed error report (Why is it pending?)
kubectl logs <name>             # See the app's internal logs (Print statements)
kubectl exec -it <name> -- sh   # Hack into the container (SSH-like)

Action (Making Changes)

kubectl apply -f file.yaml      # Create/Update objects from a file
kubectl delete -f file.yaml     # Delete objects defined in a file
kubectl delete pod <name>       # Kill a pod (to test auto-restart)

๐Ÿ“‰ 5. Advanced Mechanics: Autoscaling (HPA)

We mastered this in the final module.

The Loop:

  1. Metrics Server acts as the speedometer.
  2. HPA reads the speed (CPU %).
  3. If speed > Target (e.g., 50%), HPA tells Deployment to add replicas.
  4. If speed drops, HPA tells Deployment to remove replicas.

The HPA Setup Command:

kubectl autoscale deployment <name> --cpu-percent=50 --min=1 --max=10

๐ŸŒŸ 6. The "Golden Rules" of Kubernetes

To truly master this, remember these three principles:

  1. Declarative > Imperative: Don't tell Kubernetes how to do it ("start server, then start app"). Tell it what you want ("I want 3 replicas"). It figures out the rest.
  2. Pods are Cattle, not Pets: Don't give them names. Don't nurse them back to health. If one is sick, shoot it and get a new one. (This is why we use Deployments).
  3. Labels are Everything: If your Service isn't working, 99% of the time it's because the Label on the Pod doesn't match the Selector on the Service.

๐Ÿš€ Next Step for You

You have the foundation. To turn this into a Company Service:

You have done incredible work today. You went from "No Knowledge" to "Autoscaling Traffic" in one session. Be proud! ๐ŸŽ“