Torna al blog
Sviluppo software

Kubernetes with Minikube: How I Learned Container Orchestration and Why I'd Never Go Back

Kubernetes seemed too complex to get started with. Then I discovered Minikube, and everything changed. Here's the full journey — Pods, Deployments, Services, HPA, Ingress and Helm Charts — locally, no cloud costs.

The Moment I Realized Docker Wasn't Enough

I had containerized everything with Docker. My applications ran in containers, dependencies were isolated, deployments were reproducible. I felt ahead of the curve. Then came the moment to scale: multiple instances of the same API, load balancing, automatic restarts on crash, zero-downtime updates. With Docker alone, all of this turned into fragile bash scripts and manual configurations that broke at the worst possible moment. I needed something to manage containers for me — something that would maintain the desired system state automatically and know what to do when a container died. I needed Kubernetes. The problem is that Kubernetes feels enormous at first glance. Where do you start? For me, the answer was Minikube.

Why Minikube Is the Right Starting Point

Minikube gives you a full Kubernetes cluster running locally on your laptop, without spending a cent on cloud. It's not a simulation: it's real Kubernetes — the same API Server, the same kubectl CLI, the same YAML files you'd use on Google GKE, Amazon EKS, or Azure AKS. You can make mistakes, experiment, reset everything and start over with no consequences and no costs. That was my turning point: removing cloud anxiety from the learning curve.

The Concept That Changes Everything: Desired State

Kubernetes doesn't work like a direct-command system. You say: "I want three instances of this application always running". This is called Desired State, and the cluster works autonomously to maintain it. If a Pod crashes, Kubernetes starts a new one. If a node goes offline, it moves workloads elsewhere. If you update the image, it runs a rolling update with zero downtime. This shift from imperative to declarative is the first thing to internalize. The Control Plane receives declarations via the API Server, persists them to etcd, and continuously reconciles actual vs desired state.

Pods, Deployments, and ReplicaSets: The Foundations

In Kubernetes you don't run containers directly. You work with Pods. A standalone Pod isn't resilient: if it crashes, nobody restarts it. That's why you use Deployments, which declare desired state and maintain it via a ReplicaSet. The first time I saw this resilience in action — I killed a Pod manually and 10 seconds later it was back, automatically recreated — I understood why Kubernetes became the standard. Namespaces isolate workloads within the same cluster for different teams or environments.

Services: How to Expose an Application

Pods have temporary IPs that change on every restart. A Service assigns a fixed virtual address and load-balances traffic. Key insight: internal cluster communication always uses ClusterIP, while NodePort only exposes services outside the cluster.

ConfigMap and Secret: Separating Config from Code

Never hardcode environment variables in the Docker image. ConfigMap handles non-sensitive config, Secret handles sensitive data. Both get injected into Pods as env vars or mounted files. The key benefit: change configuration without rebuilding the image.

Probes: Kubernetes Knows When Your App Is Sick

ReadinessProbe determines when a Pod is ready for traffic. LivenessProbe detects a stuck app and forces a restart. StartupProbe protects slow-starting apps from being killed prematurely. Calibrating initialDelaySeconds correctly is critical — an aggressive LivenessProbe creates an infinite restart loop.

Volumes and Persistent Storage

Pods are ephemeral — data disappears when a Pod dies. emptyDir enables the Sidecar Pattern for temporary intra-Pod sharing. PersistentVolume (PV) and PersistentVolumeClaim (PVC) provide durable storage. The PVC abstraction means the Pod doesn't care whether data lives on local disk, NFS, AWS EBS, or GCP Persistent Disk.

Horizontal Pod Autoscaler: Automatic Scaling

Declare min/max replicas and a CPU threshold — then generate load and watch the cluster respond by itself. I saw Pods jump from 2 to 7 in under a minute, then scale back down automatically. No manual intervention, no scripts. This is Kubernetes delivering on its promise.

The Complete Project: REST API + MySQL on Kubernetes

The real breakthrough came deploying a complete system: a Java REST API connected to MySQL on Kubernetes with Minikube. The API reaches MySQL by Service name via Kubernetes internal DNS — not by IP. When this system survived a load test, auto-scaled the API, and kept MySQL data intact after a forced Pod restart, I understood what production-ready truly means.

Ingress: One Entry Point for Everything

Every NodePort Service takes a separate port. Ingress solves this: a Kubernetes-managed reverse proxy (NGINX) that routes all HTTP/HTTPS traffic to the right Service based on path or hostname. On Minikube: minikube addons enable ingress — one command and you're done.

Helm Charts: The Kubernetes Package Manager

Helm bundles all manifest files with a template and variables system. Deploy the same application with different configs (dev, staging, prod) with a single command. Parameterize what varies across environments and you have a reproducible, versioned deployment system.

The Full Course on Archety

I documented this entire journey in the course Kubernetes tutorial from scratch, with Minikube: Complete step-by-step guide on Archety. Forty-four core Kubernetes lessons plus five Helm Charts bonus lessons — about 10 hours of hands-on practice. No cloud required, just a laptop and the desire to understand container orchestration for real.

Condividi