Tech Notes

Series Kubernetes & Helm from scratch · Part 1

Kubernetes and Helm from scratch: concepts and architecture

The mental model you need before touching kubectl: what a cluster is made of, the objects you'll use daily, where Helm fits, and what we'll build.

This series is my notes from learning Kubernetes and Helm properly, by building something real rather than deploying yet another hello-world. Over 14 parts we’ll take a full-stack authentication app (a Next.js frontend, a Spring Boot API, PostgreSQL and Redis) and run it on a local Minikube cluster the way a production team would: separate namespaces, Helm charts, Ingress, metrics and logs. Nothing in it is tied to one cloud, so the same charts will run on EKS, AKS, GKE or anywhere else.

Before we install anything, it’s worth getting the mental model right. Most Kubernetes confusion comes from not knowing which part of the system is responsible for what.

What problem Kubernetes solves

Running one container is easy. Running dozens of them across several machines is not: something has to decide which machine each container runs on, restart it when it crashes, replace it when the machine dies, roll out new versions without downtime, and let containers find each other when their IP addresses keep changing.

Kubernetes does all of that, and it does it declaratively. You don’t tell it “start three containers”. You tell it “I want three copies of this running”, and it works continuously to make reality match that description. If a container dies, the cluster notices the difference and fixes it. That reconciliation loop is the single most important idea in Kubernetes.

The anatomy of a cluster

A cluster has two halves: the control plane, which makes decisions, and the worker nodes, which run your containers.

kubectl talks to the API server in the control plane, which instructs the kubelet on each worker node to run pods. kubectlyou Control plane API serverthe front door etcddesired + current state Schedulerpicks a node for each pod Controller managerfixes drift, all the time Worker node 1 kubelet kube-proxy container runtime Pod Pod Worker node 2 kubelet kube-proxy container runtime Pod
Everything goes through the API server. The kubelet on each node makes sure the pods it's been assigned are actually running.

The control plane is the brain:

  • The API server is the only way in. kubectl, Helm, your CI pipeline and the other components all talk to it.
  • etcd is a key-value store holding the cluster’s state: everything you’ve asked for, and what currently exists.
  • The scheduler decides which node each new pod should run on, based on the resources it requests.
  • The controller manager runs the reconciliation loops. When the desired state and the actual state differ, a controller acts.

Each worker node runs three things: the kubelet, an agent that starts and watches the pods assigned to its node; kube-proxy, which programs the networking so Services work; and a container runtime such as containerd, which actually runs the containers.

On Minikube, all of this lives on one node on your laptop, but the model is identical to a 100-node production cluster.

The objects you’ll use every day

You describe what you want with objects, usually written as YAML. These are the ones this series uses constantly:

Pod The smallest unit Kubernetes runs: one or more containers sharing a network address. Pods are disposable.
Deployment "Keep N copies of this pod running, and roll out new versions gradually." You'll rarely create pods directly.
ReplicaSet Created by a Deployment to hold the exact number of pods. You don't manage it yourself.
Service A stable name and IP in front of a changing set of pods, so other apps can find them.
Ingress HTTP routing from outside the cluster to Services, based on host names and paths.
Namespace A folder for objects. We'll use them to separate apps, data and monitoring.
ConfigMap Non-secret configuration, injected as environment variables or files.
Secret Like a ConfigMap, for passwords and keys. Only Base64-encoded by default, so access control matters.

How the pieces connect: labels and selectors

Objects don’t reference each other by name as much as you’d expect. Instead, they use labels (key-value tags on an object) and selectors (queries over those labels). A Deployment stamps a label such as app=auth-service on every pod it creates, and a Service sends traffic to whatever pods currently match that label.

A Deployment creates a ReplicaSet, which creates three pods labelled app=auth-service; a Service selects those pods by label. Deploymentreplicas: 3 ReplicaSetkeeps exactly 3 Podapp=auth-service Podapp=auth-service Podapp=auth-service Serviceapp=auth-service
The Deployment owns the pods; the Service only finds them by label. Replace every pod and the Service keeps working.

This loose coupling is why you can scale, roll out a new version or lose a node without reconfiguring anything. It’s also why the selector labels must stay stable over the life of an app, which comes back to bite people in Helm charts (part 3 explains how to avoid it).

Where Helm fits

Once you have a Deployment, a Service, an Ingress, a ConfigMap and a Secret for each app, in dev, staging and production, you end up copying near-identical YAML files and editing them by hand. Helm fixes that. A Helm chart is a package of templated YAML with default values; you install it as a release and override only what differs per environment:

helm install auth ./charts/auth-service -f values-prod.yaml
helm upgrade auth ./charts/auth-service --set image.tag=1.4.2
helm rollback auth 1

Helm also gives us ready-made, well-maintained charts for PostgreSQL, Redis and the whole Prometheus stack, so we don’t hand-write those.

What we’re going to build

The finished system runs in one cluster, split into three namespaces. This is the industry-standard approach: one cluster, with namespaces for logical separation, access control and resource quotas, rather than a separate cluster per component.

Requests flow from the browser through the Ingress to the Next.js frontend, then to the Spring Boot API, which uses PostgreSQL and Redis in the data namespace; Prometheus, Grafana and Loki run in the monitoring namespace. Browseryour users Minikube cluster (any cloud later) IngressNGINX controller namespace: apps Next.js frontendUI + server actions Spring Boot APIauth, MFA, JWT namespace: data PostgreSQLusers (Bitnami chart) RedisMFA codes (Bitnami) namespace: monitoring Prometheusscrapes metrics Grafana + Lokidashboards and logs
The target architecture. Orange lines are live request paths; the dotted line is Prometheus scraping the API's metrics.

A few design choices are worth calling out now:

  • The frontend and backend live in apps; the databases live in data. Stateful services have very different lifecycles, backup needs and access rules from stateless apps, so they’re kept apart.
  • Apps find each other by DNS, not IP addresses. The backend connects to something like postgresql.data.svc.cluster.local, which keeps working however often pods are replaced.
  • Only the Ingress is exposed. Everything else uses internal ClusterIP Services.
  • Nothing is cloud-specific. No load balancer annotations, no managed-database assumptions: the same charts deploy anywhere.

The roadmap

  1. Foundation (parts 1–3) Concepts, Minikube and your first deployment, then Helm fundamentals and your first chart.
  2. Application development (parts 4–6) The Spring Boot auth API, the Next.js frontend, and containerising both.
  3. Stateful services (parts 7–8) PostgreSQL and Redis with Bitnami's Helm charts.
  4. Application deployment (parts 9–11) Our own Helm charts for both apps, then Ingress, service discovery and an umbrella chart.
  5. Observability (parts 12–13) Metrics with Prometheus and Grafana, and logs with Loki.
  6. Production readiness (part 14) Secrets, resource limits, health checks and autoscaling.

Takeaways

  • Kubernetes is declarative: you describe the desired state and controllers keep reality in line with it.
  • The control plane decides; the kubelet on each node does. Everything goes through the API server.
  • Deployments own pods, Services find them by label, and Ingress routes outside traffic to Services.
  • Helm turns repetitive YAML into versioned, configurable packages you install, upgrade and roll back.
  • One cluster, separate namespaces, DNS-based discovery and no cloud-specific settings keeps the setup portable.

Next, in part 2, we start Minikube, create the namespaces and deploy our first workload.