Inkpost, home
Dark cover with the title "The Kubernetes ecosystem, end to end", the tagline "Describe it. The cluster keeps it true." and a drawing of one control plane linked to three worker nodes.

Cloud & DevOps · Kubernetes

The Kubernetes ecosystem, end to end: every module set up, with working code

From kind on your laptop to Gateway API, KEDA, Kyverno, Helm, Argo CD, Prometheus, CloudNativePG and Velero: one results-day app taken to production on Kubernetes 1.37, with setup steps and validated manifests for every piece.

Suman AcharyyaVerified@sumanacharyya999

30 min read

A container is an app packed with everything it needs to run, so it behaves the same on a laptop and on a server. Starting one takes a single command. Running a real product is different: dozens of services, each with several copies, spread over many machines, while traffic swings and machines fail. Kubernetes is the system most teams now use for that job. This post walks through the whole ecosystem, from the core objects to the tools around them, with a working manifest or command for every part.Source [1]

Why a thousand containers are a different problem

Picture a board-exam results site. Results go live at 10:00. At 09:59 a few thousand students are refreshing the page; at 10:01 there are four hundred thousand. The site is a handful of services: a web front end, a results API, a queue that holds people when it's full, and a PostgreSQL database. On a quiet day five copies of the API are plenty. This morning it needs fifty, spread over many servers. If a server dies at 10:04, its copies must come back somewhere else within seconds, and by 13:00 most of them should be gone so nobody pays for idle machines.

No person with a script can react that fast. Kubernetes can, because it was built to keep a group of machines running what you described, placing work, replacing what fails and resizing as load changes. But whether students notice the 10:04 failure depends mostly on what the team prepared the day before. That preparation is what the rest of this post is about.

Cluster architecture diagram. You send YAML to the API server. The control plane (API server, etcd, scheduler, controllers) decides where pods run. Three worker nodes run them through kubelet, kube-proxy and the container runtime.
You describe, the control plane decides, the nodes do it.

1. The idea underneath everything: desired state

You don't tell Kubernetes what to do step by step. You tell it what should be true: five copies of the results API, this exact image, reachable on port 80. Kubernetes stores that description and then compares it, over and over, with what is really running. Five wanted and four running means it starts one more. A node stops answering, and once it is sure the node is gone, it recreates that node's pods elsewhere. Each of these comparers is a controller, and the never-ending compare-and-fix cycle is called a control loop.Source [3]

In robotics and automation, a control loop is a non-terminating loop that regulates the state of a system.

Kubernetes documentation, "Controllers"

Once this clicks, the vocabulary stops being scary. Almost every object you will meet is either a description of something that should be true, or a controller that keeps one true. Kubernetes came out of Google's experience running containers at very large scale, was open-sourced in 2014, and is now looked after by the Cloud Native Computing Foundation (CNCF).Source [1]

2. The cluster: who does what

A cluster is a group of machines working as one. The machines that run your apps are nodes; the part that runs the cluster itself is the control plane. Here is every piece and its one job:Source [4]

  • API server (kube-apiserver): the front door. Every request, from you or from inside the cluster, comes through it. It checks who you are, whether you're allowed, and whether the object is valid, then stores it.

  • etcd: the cluster's memory, a replicated key-value store holding every object and its status. Lose it and the cluster forgets what it should be running.

  • Scheduler (kube-scheduler): picks a node for every new pod, based on requested resources, rules and spread.

  • Controller manager (kube-controller-manager): runs the built-in control loops (Deployments, ReplicaSets, Jobs, nodes, endpoints and more).

  • Cloud controller manager: talks to your cloud for load balancers, routes and node lifecycle.

  • kubelet (on every node): makes sure the pods assigned to its node are running and healthy, and reports back.

  • Container runtime (usually containerd): actually pulls images and starts containers when the kubelet asks.

  • kube-proxy or the network plugin (on every node): makes Service addresses route to healthy pods.

  • CoreDNS: gives every Service a DNS name, so apps call results-api instead of an IP address.

Notice what's missing: nobody sends anybody orders. You write an object to the API server; a controller notices and creates pods; the scheduler notices pods without a node and assigns them; each kubelet notices pods assigned to it and starts them. Every component watches the API server and does its own job when something changes. That's why one slow component doesn't stop the rest. In short: you describe, the control plane decides, the nodes do it.

3. Get a cluster to practise on

For learning, kind runs a whole cluster inside containers on your laptop. The config below creates one control plane and three workers, and labels each worker with a pretend availability zone, so the spreading rules later in this post behave like they would in the cloud.Source [6]

# kind-cluster.yaml: one control plane, three workers in three pretend zoneskind: ClusterapiVersion: kind.x-k8s.io/v1alpha4name: resultsnodes:- role: control-plane- role: worker  labels:    topology.kubernetes.io/zone: zone-a- role: worker  labels:    topology.kubernetes.io/zone: zone-b- role: worker  labels:    topology.kubernetes.io/zone: zone-c
# Tools (pick your OS). kubectl should be within one minor version of the cluster.brew install kubectl kind helm               # macOSwinget install Kubernetes.kubectl Kubernetes.kind Helm.Helm   # Windows# Linux: Helm 4's official scriptcurl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-4chmod 700 get_helm.sh && ./get_helm.sh# A 4-node cluster on your laptop (Docker or Podman must be running)kind create cluster --config kind-cluster.yamlkubectl get nodes -L topology.kubernetes.io/zonekubectl cluster-info

For production, most teams use a managed cluster: Amazon EKS, Azure Kubernetes Service or Google Kubernetes Engine run the control plane for you. Managed doesn't mean finished, though. You still own the nodes, networking, add-ons, security settings, backups, app upgrades and the bill. Always spread nodes over at least three zones.Source [7]

# Managed control planes (dummy names; each takes ~10-15 minutes)eksctl create cluster --name results-prod --region ap-south-1 \  --zones ap-south-1a,ap-south-1b,ap-south-1c --nodes 3 --node-type m7i.largeaz aks create --resource-group results-rg --name results-prod \  --zones 1 2 3 --node-count 3 --node-vm-size Standard_D4s_v5 --generate-ssh-keysgcloud container clusters create results-prod --region asia-south1 \  --num-nodes 1 --machine-type e2-standard-4     # 1 node per zone x 3 zoneskubectl config get-contexts                       # each command adds a context

4. Workloads: Pods, Deployments and friends

The smallest thing Kubernetes runs is a Pod: one container, or a few that must always live together and share one network address. Pods are disposable. If a container crashes, the kubelet restarts it inside the same pod, but if the pod is deleted or its node dies, that pod is gone for good and nothing brings it back unless something owns it. That's why you almost never create pods directly. You create a Deployment, which keeps a set number of identical pods alive and handles new versions for you.Source [8]

apiVersion: apps/v1kind: Deploymentmetadata:  name: results-api  namespace: results  labels:    app: results-apispec:  replicas: 5                       # desired state: five copies  revisionHistoryLimit: 5  selector:    matchLabels:      app: results-api  strategy:    type: RollingUpdate    rollingUpdate:      maxUnavailable: 0             # never drop below five ready pods during an update      maxSurge: 25%                 # allow a few extra pods while new ones start  template:    metadata:      labels:        app: results-api    spec:      serviceAccountName: results-api      automountServiceAccountToken: false      terminationGracePeriodSeconds: 45      securityContext:        runAsNonRoot: true        runAsUser: 10001        seccompProfile:          type: RuntimeDefault      containers:      - name: api        # tag for people, digest for machines: every node runs the same bytes        image: registry.example.com/results-api:3.1.0@sha256:0000000000000000000000000000000000000000000000000000000000000000        ports:        - name: http          containerPort: 8080        envFrom:        - configMapRef:            name: results-config        env:        - name: SMS_API_KEY          valueFrom:            secretKeyRef:              name: results-secrets              key: sms-api-key        resources:          requests:            cpu: 500m            memory: 512Mi          limits:            memory: 1Gi             # memory limit protects the node; no CPU limit avoids throttling        startupProbe:          httpGet:            path: /healthz            port: http          periodSeconds: 2          failureThreshold: 30      # up to 60 s to boot        livenessProbe:          httpGet:            path: /healthz          # checks the process only, never the database            port: http          periodSeconds: 10          failureThreshold: 3        readinessProbe:          httpGet:            path: /ready            # may check dependencies: not ready = no traffic, no restart            port: http          periodSeconds: 5          failureThreshold: 2        lifecycle:          preStop:            sleep:              seconds: 10           # let endpoint removal reach every node before shutdown        securityContext:          allowPrivilegeEscalation: false          readOnlyRootFilesystem: true          capabilities:            drop: ["ALL"]      tolerations:                  # default is 300 s: replace pods from a dead node after 30 s instead      - key: node.kubernetes.io/unreachable        operator: Exists        effect: NoExecute        tolerationSeconds: 30      - key: node.kubernetes.io/not-ready        operator: Exists        effect: NoExecute        tolerationSeconds: 30      topologySpreadConstraints:      - maxSkew: 1        topologyKey: topology.kubernetes.io/zone        whenUnsatisfiable: DoNotSchedule        labelSelector:          matchLabels:            app: results-api      - maxSkew: 1        topologyKey: kubernetes.io/hostname        whenUnsatisfiable: ScheduleAnyway        labelSelector:          matchLabels:            app: results-api

Read it top to bottom. replicas: 5 is the desired state. The label app: results-api is a name tag that the Service, the disruption budget and the spread rules all use to find these pods. The image has a version tag for people and a sha256 digest for machines: a tag can be moved to different contents later, a digest can't, so every node runs exactly the same bytes. The probes, resources, tolerations and spread rules matter on results day; we'll come back to each of them. One of them is easy to miss: by default, pods on a node that stops responding wait five minutes before they're evicted and replaced. The two tolerations cut that to 30 seconds.Source [9]

kubectl apply -f namespace.yamlkubectl apply -f config.yaml -f rbac.yaml -f deployment.yaml -f service.yamlkubectl -n results rollout status deployment/results-api   # waits until 5/5 are readykubectl -n results get pods -o wide                         # which node and zone each pod gotkubectl -n results get endpointslices -l kubernetes.io/service-name=results-api

Updates, rollbacks and shutting down cleanly

When you change the image, the Deployment rolls the update out a few pods at a time: it starts new pods, waits until they're ready, then removes old ones. maxUnavailable: 0 means capacity never drops during an update, and maxSurge: 25% allows a few extra pods while new ones start, so leave spare room on your nodes for them.Source [10]

Getting pods out matters as much as getting them in. When a pod is deleted, Kubernetes marks it as terminating, removes it from Services and sends the app SIGTERM; after the grace period (30 seconds by default) it sends SIGKILL. Removal from Services takes a moment to reach every node, so a few requests can still arrive. The preStop sleep holds the shutdown for 10 seconds while that happens; then the app must stop accepting new work, finish what it has, and exit before terminationGracePeriodSeconds runs out. Skip this and every deploy drops a few users.Source [11]

# Ship 3.2.0: change the image, watch it roll, and undo if it misbehaveskubectl -n results set image deployment/results-api \  api=registry.example.com/results-api:3.2.0@sha256:1111111111111111111111111111111111111111111111111111111111111111kubectl -n results rollout status deployment/results-apikubectl -n results rollout history deployment/results-apikubectl -n results rollout undo deployment/results-api            # back to the previous revisionkubectl -n results rollout undo deployment/results-api --to-revision=3

Other workload types

Object

Use it for

In this post

Deployment

Stateless apps: identical, replaceable pods

results-api

StatefulSet

Pods that need a stable name and their own disk

Used under the hood by the database operator

DaemonSet

Exactly one pod per node: log and metrics agents

log-agent

Job

Run a task until it succeeds, then stop

Importing the marks file

CronJob

Run a Job on a schedule

The nightly report at 01:30 IST

apiVersion: apps/v1kind: DaemonSetmetadata:  name: log-agent  namespace: resultsspec:  selector:    matchLabels:      app: log-agent  template:    metadata:      labels:        app: log-agent    spec:      containers:      - name: agent        image: registry.example.com/log-agent:1.4.2        resources:          requests: { cpu: 50m, memory: 64Mi }          limits: { memory: 128Mi }---apiVersion: batch/v1kind: Jobmetadata:  name: import-marks-2026  namespace: resultsspec:  backoffLimit: 3  ttlSecondsAfterFinished: 86400  template:    spec:      restartPolicy: Never      containers:      - name: import        image: registry.example.com/results-api:3.1.0        command: ["/app/bin/import", "--batch", "2026-board"]---apiVersion: batch/v1kind: CronJobmetadata:  name: nightly-report  namespace: resultsspec:  schedule: "30 1 * * *"  timeZone: Asia/Kolkata  concurrencyPolicy: Forbid  jobTemplate:    spec:      template:        spec:          restartPolicy: OnFailure          containers:          - name: report            image: registry.example.com/results-api:3.1.0            command: ["/app/bin/report"]

5. Networking: Services, DNS, Gateway API and policies

Pods come and go and each new pod gets a new IP, so nothing should call a pod's IP. A Service gives a group of pods one stable name and virtual IP, and spreads traffic across the ones that are ready. It finds its pods by label: this one selects every pod labelled app: results-api. When a Service seems broken, check the labels first; a selector that matches nothing is one of the most common mistakes. Inside the cluster, the front end simply calls http://results-api.results.Source [12]

apiVersion: v1kind: Servicemetadata:  name: results-api  namespace: resultsspec:  selector:    app: results-api                # must match the pod labels exactly  ports:  - name: http    port: 80    targetPort: http

Most Services are only reachable inside the cluster. To let the internet in, you could give each one its own cloud load balancer, but that gets expensive fast. Instead, one shared entry point routes requests by host name and path. For years that was Ingress, usually with the ingress-nginx controller. That controller was retired in March 2026 and gets no more releases or security fixes, so new setups should start with Gateway API, its successor. Gateway API splits the job by role: the platform team owns the GatewayClass and the Gateway (ports, TLS, which namespaces may attach), and each app team owns its own HTTPRoutes.Source [13]Source [14]

# 1) The Gateway API CRDs (standard channel)kubectl apply --server-side -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.7.0/standard-install.yaml# 2) An implementation: Envoy Gatewayhelm install eg oci://docker.io/envoyproxy/gateway-helm --version v1.10.0 \  -n envoy-gateway-system --create-namespace# 3) Let the results namespace attach routes, then apply the objectskubectl label namespace results gateway-access=publickubectl apply -f gateway.yamlkubectl -n results get httproute results-api -o yaml | grep -A5 conditions
# Owned by the platform teamapiVersion: gateway.networking.k8s.io/v1kind: GatewayClassmetadata:  name: egspec:  controllerName: gateway.envoyproxy.io/gatewayclass-controller---apiVersion: gateway.networking.k8s.io/v1kind: Gatewaymetadata:  name: public  namespace: envoy-gateway-systemspec:  gatewayClassName: eg  listeners:  - name: https    protocol: HTTPS    port: 443    hostname: "*.example.com"    tls:      mode: Terminate      certificateRefs:      - name: wildcard-example-com    # a TLS Secret, e.g. issued by cert-manager    allowedRoutes:      namespaces:        from: Selector        selector:          matchLabels:            gateway-access: public---# Owned by the app team, in its own namespace (label it gateway-access=public)apiVersion: gateway.networking.k8s.io/v1kind: HTTPRoutemetadata:  name: results-api  namespace: resultsspec:  parentRefs:  - name: public    namespace: envoy-gateway-system  hostnames: ["results.example.com"]  rules:  - matches:    - path:        type: PathPrefix        value: /api    backendRefs:    - name: results-api      port: 80

Underneath, a network plugin (CNI) connects every pod to every other pod, and by default all of them can talk to all of them. That's convenient until one pod is compromised. Start each namespace with a policy that denies all traffic in and out, then allow only what's needed: DNS, the gateway to the API, the API to the database. Check that your network plugin actually enforces NetworkPolicy; a plugin that doesn't support it silently ignores these objects.Source [15]

# 1) Deny everything in and out of the namespaceapiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata:  name: default-deny  namespace: resultsspec:  podSelector: {}  policyTypes: ["Ingress", "Egress"]---# 2) Let every pod resolve names through CoreDNSapiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata:  name: allow-dns  namespace: resultsspec:  podSelector: {}  policyTypes: ["Egress"]  egress:  - to:    - namespaceSelector:        matchLabels:          kubernetes.io/metadata.name: kube-system      podSelector:        matchLabels:          k8s-app: kube-dns    ports:    - protocol: UDP      port: 53    - protocol: TCP      port: 53---# 3) The gateway may reach the API; the API may reach the databaseapiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata:  name: results-api  namespace: resultsspec:  podSelector:    matchLabels:      app: results-api  policyTypes: ["Ingress", "Egress"]  ingress:  - from:    - namespaceSelector:        matchLabels:          kubernetes.io/metadata.name: envoy-gateway-system    ports:    - protocol: TCP      port: 8080  egress:  - to:    - podSelector:        matchLabels:          cnpg.io/cluster: results-db    ports:    - protocol: TCP      port: 5432

6. Configuration, secrets and storage

The same image runs in testing and production, so settings that differ must live outside it. A ConfigMap holds ordinary settings; a Secret holds sensitive ones like the SMS provider's key. The Deployment reads both as environment variables (they can also be mounted as files).

apiVersion: v1kind: ConfigMapmetadata:  name: results-config  namespace: resultsdata:  DB_HOST: results-db-rw.results.svc.cluster.local  SMS_PROVIDER_URL: https://sms.example.com/v2  REQUEST_TIMEOUT: 5s---apiVersion: v1kind: Secretmetadata:  name: results-secrets  namespace: resultstype: OpaquestringData:                          # stored base64-encoded, NOT encrypted, unless you enable encryption at rest  sms-api-key: dummy-sms-key-7f3a9c

A Secret is not encrypted by default. Its values are only base64-encoded and stored as-is in etcd, so anyone who can read Secrets in a namespace, or create a pod there, can read the values in seconds. Three habits fix most of this: limit get and list on Secrets with RBAC, turn on encryption at rest (managed clusters offer a switch or a KMS key; self-managed clusters use the file below), and keep the real values in a secret manager, syncing them in with External Secrets Operator.Source [16]Source [17]

# /etc/kubernetes/enc/encryption-config.yaml on every control-plane node (self-managed clusters)apiVersion: apiserver.config.k8s.io/v1kind: EncryptionConfigurationresources:- resources: ["secrets"]  providers:  - aescbc:      keys:      - name: key-2026-11        secret: ZHVtbXktMzItYnl0ZS1rZXktZm9yLWRvY3Mtb25seS0wMA==   # dummy; generate with: head -c 32 /dev/urandom | base64  - identity: {}                      # lets the API server still read old, unencrypted secrets# then start kube-apiserver with: --encryption-provider-config=/etc/kubernetes/enc/encryption-config.yaml
apiVersion: external-secrets.io/v1kind: SecretStoremetadata:  name: aws-sm  namespace: resultsspec:  provider:    aws:      service: SecretsManager      region: ap-south-1      auth:        jwt:          serviceAccountRef:            name: external-secrets-reader   # mapped to a cloud IAM role, no static keys---apiVersion: external-secrets.io/v1kind: ExternalSecretmetadata:  name: results-secrets  namespace: resultsspec:  refreshInterval: 1h  secretStoreRef:    name: aws-sm    kind: SecretStore  target:    name: results-secrets            # the Kubernetes Secret the Deployment reads    creationPolicy: Owner  data:  - secretKey: sms-api-key    remoteRef:      key: prod/results/sms      property: api_key

Anything that must outlive a pod needs storage outside it. The app asks for a disk with a PersistentVolumeClaim, and the StorageClass tells the cluster how to create one automatically. Check reclaimPolicy: many default classes use Delete, so deleting the claim deletes the disk and its data. And remember that a disk that survives is still not a backup.Source [18]

apiVersion: storage.k8s.io/v1kind: StorageClassmetadata:  name: fast-retainprovisioner: ebs.csi.aws.com         # your cloud's CSI driverreclaimPolicy: Retain                # keep the disk when the claim is deletedallowVolumeExpansion: truevolumeBindingMode: WaitForFirstConsumerparameters:  type: gp3---apiVersion: v1kind: PersistentVolumeClaimmetadata:  name: uploads  namespace: resultsspec:  accessModes: ["ReadWriteOnce"]  storageClassName: fast-retain  resources:    requests:      storage: 50Gi

Databases deserve a special word. A StatefulSet gives each pod a fixed name and its own disk, but it doesn't copy data, elect a leader or fail over safely: that's the database's job. Either use a managed database (RDS, Cloud SQL, Azure Database), or use an operator, a controller that runs a database the way an experienced DBA would. CloudNativePG does this for PostgreSQL: three instances, streaming replication, automatic failover and scheduled backups to object storage through its Barman Cloud plugin.Source [19]

apiVersion: postgresql.cnpg.io/v1kind: Clustermetadata:  name: results-db  namespace: resultsspec:  instances: 3                        # one primary, two replicas, automatic failover  storage:    size: 100Gi    storageClass: fast-retain  plugins:                            # continuous backup + WAL archiving via the Barman Cloud plugin  - name: barman-cloud.cloudnative-pg.io    isWALArchiver: true    parameters:      barmanObjectName: results-backups   # an ObjectStore that points at your bucket---apiVersion: postgresql.cnpg.io/v1kind: ScheduledBackupmetadata:  name: results-db-daily  namespace: resultsspec:  schedule: "0 0 1 * * *"             # six fields: seconds first; 01:00 every day  cluster:    name: results-db  method: plugin  pluginConfiguration:    name: barman-cloud.cloudnative-pg.io

For the rest of the namespace (every object plus volume snapshots), Velero takes scheduled backups you can restore into the same or a brand-new cluster.Source [20]

# Back up the whole namespace (objects + volume snapshots) every night, keep 30 daysvelero schedule create results-nightly \  --schedule="0 2 * * *" \  --include-namespaces results \  --ttl 720h0m0s# Restore into a fresh cluster or after a mistakevelero restore create --from-backup results-nightly-20261125020000

7. Getting ready for the rush

The team didn't guess its numbers. A week earlier it ran a load test: one API pod handles about 150 requests per second at 0.5 CPU, uses up to 20 database connections, and the first thing to break is the database connection pool, not the API. It also agreed what a good morning looks like: 99.9% of requests succeed and 95% finish in under 300 ms. Everything below comes from those measurements.

Resources first. A request is what the scheduler uses to decide where a pod fits; a limit is a ceiling. A container that hits its CPU limit is slowed down; one that goes over its memory limit is killed and restarted. Pods with no requests at all are in the BestEffort class and are among the first evicted when a node runs short. Our Deployment requests 0.5 CPU and 512 MiB, caps memory at 1 GiB and sets no CPU limit, so it can use spare CPU without being throttled.Source [21]

Then probes. A startup probe gives a slow-booting app time before the other checks begin. A liveness probe asks 'is the process stuck?' and restarts it if so. A readiness probe asks 'can it take traffic right now?' and, if not, only removes the pod from the Service. Here's the classic mistake: a liveness probe that also checks the database. The database slows for a few seconds, every API pod fails liveness at once, and Kubernetes restarts all of them together. A small slowdown becomes a full outage. Liveness checks the app only; dependencies belong in readiness.Source [22]

Then placement. The scheduler tries to spread pods but doesn't promise to, so the Deployment's topologySpreadConstraints require an even spread across zones and prefer an even spread across nodes. If a whole zone fails, the other two keep serving, as long as there's room. A PodDisruptionBudget protects that spread during voluntary disruptions such as node drains and upgrades: with minAvailable: 80% a drain can never take more than a fifth of the API at once. It does not protect against a node crashing, someone deleting pods directly, or a bad rollout; those need the other safeguards in this post.Source [23]Source [24]

apiVersion: policy/v1kind: PodDisruptionBudgetmetadata:  name: results-api  namespace: resultsspec:  minAvailable: 80%                  # drains may never take more than 20% at once  selector:    matchLabels:      app: results-api---apiVersion: autoscaling/v2kind: HorizontalPodAutoscalermetadata:  name: results-api  namespace: resultsspec:  scaleTargetRef:    apiVersion: apps/v1    kind: Deployment    name: results-api  minReplicas: 5  maxReplicas: 80  metrics:  - type: Resource    resource:      name: cpu      target:        type: Utilization        averageUtilization: 60       # percent of the CPU *request*  behavior:    scaleUp:      stabilizationWindowSeconds: 0      policies:      - type: Percent        value: 100                    # may double every 30 s        periodSeconds: 30    scaleDown:      stabilizationWindowSeconds: 300 # wait 5 min before shrinking

Finally, scaling, which happens in layers. The HorizontalPodAutoscaler (HPA) adds and removes pods; for CPU it needs metrics-server. Kubernetes 1.37 made the Metrics API behind it (metrics.k8s.io) stable, and HPA scale-to-zero is now beta and on by default: with minReplicas: 0 and an object or external metric, an idle app can drop to zero pods. CPU and memory can't do that, because they need running pods to measure, and a results site shouldn't sleep on results day anyway. KEDA scales on better signals for a spike like this, such as requests per second or queue length from Prometheus. The Cluster Autoscaler or Karpenter adds nodes when pods don't fit. None of it is instant: noticing load takes seconds, starting pods takes more, and new nodes take minutes. Four hundred thousand students won't wait, so the team raises the floor before 10:00.Source [25]Source [26]

# Results day, plain HPA version: raise the floor before the rush ...
kubectl -n results patch hpa results-api --type merge -p '{"spec":{"minReplicas":40}}'
kubectl -n results get hpa results-api -w
# ... and put it back after
kubectl -n results patch hpa results-api --type merge -p '{"spec":{"minReplicas":5}}'
# Don't "kubectl scale deployment" while an HPA owns it: the HPA sets replicas straight back.

With KEDA, the same plan fits in one object: a cron trigger holds at least 40 pods from 09:30 to 12:30, and a Prometheus trigger scales on real traffic above that. KEDA creates and manages its own HPA, so remove the plain HPA first and never run both on one Deployment.Source [27]Source [28]

# KEDA creates and manages the HPA for you: delete the plain HPA first, never run bothapiVersion: keda.sh/v1alpha1kind: ScaledObjectmetadata:  name: results-api  namespace: resultsspec:  scaleTargetRef:    name: results-api  minReplicaCount: 5  maxReplicaCount: 80  cooldownPeriod: 300  triggers:  # Hold at least 40 pods from 09:30 to 12:30 on results day  - type: cron    metadata:      timezone: Asia/Kolkata      start: 30 9 25 11 *      end: 30 12 25 11 *      desiredReplicas: "40"  # Then scale on real traffic: one pod per 150 requests per second  - type: prometheus    metadata:      serverAddress: http://kube-prometheus-stack-prometheus.monitoring.svc:9090      query: sum(rate(http_requests_total{namespace="results",service="results-api"}[1m]))      threshold: "150"      activationThreshold: "5"
Transcript
Kubernetes runs your containers across a group of machines and keeps them the way you described. You describe what should be true. A control loop compares it with reality and fixes the difference. The API server and etcd store that description. The scheduler and controllers act on it. Each node's kubelet runs the pods. Deployments keep identical pods alive, roll out updates without losing capacity, and shut pods down cleanly. Services give pods one stable name. Gateway API lets the internet in. Network policies allow only what's needed. Before a traffic spike: set requests and honest probes, spread across zones, and raise the autoscaler's floor early. Security starts with RBAC and namespaces, then pod security levels and a policy engine for company rules. Around the core: Helm packages apps, GitOps deploys them, Prometheus watches them, operators run databases. When a release breaks, gather evidence: get, describe, logs. Roll back first, then investigate.

8. Results day, minute by minute

  1. 09:00: the dashboards are green; nodes for 40 pods are already running in three zones.

  2. 09:30: KEDA's cron trigger raises the floor to 40 pods. They start, pass their startup and readiness probes and join the Service.

  3. 10:00: results go live. Requests per second jump twentyfold; the Prometheus trigger takes the API to 55 pods and the Cluster Autoscaler adds two nodes.

  4. 10:04: a node in zone-b dies. Its pods stop answering; the others keep serving because the spread rule kept 2/3 of capacity elsewhere.

  5. 10:05: after under a minute without heartbeats the node is marked NotReady; 30 seconds later (the toleration in the Deployment, instead of the default five minutes) its pods are evicted, and the scheduler places replacements on healthy nodes with room.

  6. 10:20: the database, not the API, is now the limit. More API pods wouldn't help, so the team leans on the waiting-room queue instead of scaling further.

  7. 12:30: the cron window closes; five minutes of cooldown later, KEDA scales back down and the autoscaler removes the spare nodes.

Kubernetes did the replacing, but the outcome was decided the day before: load-tested numbers, honest probes, spread rules, spare room and a pre-raised floor. Autoscaling also only helps what can scale; when the database or a third-party API is the bottleneck, more pods just add load.

9. Security: who can do what, and what pods may do

With many teams on one cluster, start with access. RBAC (role-based access control) has two parts: a Role lists allowed actions, and a RoleBinding grants it to a user, group or service account. Namespaces separate teams, ResourceQuotas stop one team using the whole cluster, LimitRanges give sensible defaults to pods that forgot their requests, and every app gets its own ServiceAccount with no more permissions than its job needs. The results API never calls the Kubernetes API, so it gets no token at all.Source [29]

apiVersion: v1kind: ServiceAccountmetadata:  name: results-api  namespace: resultsautomountServiceAccountToken: false   # the app never calls the Kubernetes API---apiVersion: rbac.authorization.k8s.io/v1kind: Rolemetadata:  name: deployer  namespace: resultsrules:- apiGroups: ["apps"]  resources: ["deployments"]  verbs: ["get", "list", "watch", "update", "patch"]- apiGroups: [""]  resources: ["pods", "pods/log"]  verbs: ["get", "list", "watch"]---apiVersion: rbac.authorization.k8s.io/v1kind: RoleBindingmetadata:  name: results-team-deployer  namespace: resultssubjects:- kind: Group  name: results-team                  # from your identity provider  apiGroup: rbac.authorization.k8s.ioroleRef:  kind: Role  name: deployer  apiGroup: rbac.authorization.k8s.io---apiVersion: v1kind: ResourceQuotametadata:  name: results-quota  namespace: resultsspec:  hard:    requests.cpu: "60"    requests.memory: 120Gi    limits.memory: 200Gi    pods: "150"---apiVersion: v1kind: LimitRangemetadata:  name: defaults  namespace: resultsspec:  limits:  - type: Container    defaultRequest:      cpu: 100m      memory: 128Mi    default:      memory: 256Mi

Next, control what a container may do on its node: run as a non-root user, drop all Linux capabilities, block privilege escalation and keep the root filesystem read-only, as our Deployment does. Pod Security Admission enforces shared levels (privileged, baseline, restricted) per namespace through labels. It does nothing until you set them. Most teams start by warning at restricted while enforcing baseline, fix whatever the warnings show, then enforce restricted.Source [30]

apiVersion: v1kind: Namespacemetadata:  name: results  labels:    # Pod Security Admission: start by warning, enforce once the warnings are gone    pod-security.kubernetes.io/warn: restricted    pod-security.kubernetes.io/warn-version: latest    pod-security.kubernetes.io/enforce: baseline    pod-security.kubernetes.io/enforce-version: latest

Company rules that the built-in levels don't cover, such as 'images only from our registry, pinned by digest', belong in a policy engine. Kyverno's ValidatingPolicy writes the rule as a CEL expression and checks every pod at admission.Source [31]

apiVersion: policies.kyverno.io/v1kind: ValidatingPolicymetadata:  name: only-company-registryspec:  validationActions:  - Audit                              # switch to Deny once the reports are clean  matchConstraints:    resourceRules:    - apiGroups: [""]      apiVersions: ["v1"]      operations: ["CREATE", "UPDATE"]      resources: ["pods"]  validations:  - message: "Images must come from registry.example.com and be pinned by digest."    expression: >-      object.spec.containers.all(c,        c.image.startsWith('registry.example.com/') && c.image.contains('@sha256:'))

10. The ecosystem around the core

Ecosystem map with Kubernetes in the middle and tool groups around it: Helm for packaging, Argo CD and Flux for GitOps, Prometheus and Grafana for metrics, Gateway API for traffic, KEDA, Kyverno, operators and Velero.
The ecosystem around the core: pick one tool per job, not all of them.

Area

Tool in this post

What it keeps true

Packaging

Helm

One versioned chart per app, different values per environment

Delivery

Argo CD or Flux (GitOps)

The cluster matches Git; manual changes are undone

Traffic

Gateway API + Envoy Gateway

Outside requests reach the right Service, with TLS

Scaling

HPA, KEDA, Cluster Autoscaler or Karpenter

Enough pods and nodes for the load, and no more

Secrets

External Secrets Operator

Kubernetes Secrets match the cloud secret manager

Policy

Pod Security Admission + Kyverno

Only compliant pods are admitted

Data

CloudNativePG, Velero

A highly available database and restorable backups

Visibility

Prometheus, Grafana, Alertmanager, central logs

You see problems before users report them

# Metrics for kubectl top and CPU-based HPAkubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml# Prometheus, Alertmanager and Grafana in one charthelm repo add prometheus-community https://prometheus-community.github.io/helm-chartshelm install kube-prometheus-stack prometheus-community/kube-prometheus-stack \  -n monitoring --create-namespace# Event-driven autoscalinghelm repo add kedacore https://kedacore.github.io/chartshelm install keda kedacore/keda -n keda --create-namespace# Policy enginehelm repo add kyverno https://kyverno.github.io/kyverno/helm install kyverno kyverno/kyverno -n kyverno --create-namespace# Secrets from a vault or cloud secret managerhelm repo add external-secrets https://charts.external-secrets.iohelm install external-secrets external-secrets/external-secrets \  -n external-secrets --create-namespace# PostgreSQL operatorhelm repo add cnpg https://cloudnative-pg.github.io/chartshelm install cnpg cnpg/cloudnative-pg -n cnpg-system --create-namespacehelm repo update && helm list -A

Helm: package once, configure per environment

Twenty YAML files per app, slightly different in every environment, get out of hand quickly. Helm packages them into a chart: templates with placeholders plus a values.yaml of defaults, and a small values file per environment for what differs. Installs and upgrades become numbered releases you can list and roll back.Source [32]

# A chart is a folder: templates + default valueshelm create results-api        # scaffolds Chart.yaml, values.yaml, templates/tree results-api# results-api/#   Chart.yaml            name, version, appVersion#   values.yaml           defaults (replicas, image, resources ...)#   values-prod.yaml      only what differs in production#   templates/            deployment.yaml, service.yaml, hpa.yaml ... with {{ .Values.* }}helm lint results-apihelm template results-api ./results-api -f results-api/values-prod.yaml | less   # render, don't installhelm upgrade --install results-api ./results-api -n results -f results-api/values-prod.yaml \  --atomic --timeout 5m          # rolls back by itself if the release failshelm history results-api -n resultshelm rollback results-api 4 -n results

GitOps: Git is the source of truth

Running kubectl apply from laptops means nobody knows what's really deployed. With GitOps, the desired state lives in a Git repository and an agent in the cluster, Argo CD or Flux, keeps the cluster matching it: merge a pull request and the change rolls out; edit something by hand and it's put back. Every change gets a review and an audit trail, and rolling back is a git revert.Source [33]Source [34]

apiVersion: argoproj.io/v1alpha1kind: Applicationmetadata:  name: results-api  namespace: argocdspec:  project: default  source:    repoURL: https://git.example.com/platform/results-deploy.git    targetRevision: main    path: charts/results-api    helm:      valueFiles:      - values-prod.yaml  destination:    server: https://kubernetes.default.svc    namespace: results  syncPolicy:    automated:      prune: true          # delete what was removed from Git      selfHeal: true       # undo changes made by hand with kubectl    syncOptions:    - CreateNamespace=true    - ServerSideApply=true
# Argo CDkubectl create namespace argocdkubectl apply -n argocd --server-side --force-conflicts \  -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yamlargocd admin initial-password -n argocd     # then change it and delete argocd-initial-admin-secretkubectl apply -f argocd-application.yaml# ...or Flux (pick one GitOps tool per cluster)export GITHUB_TOKEN=ghp_dummyDummyDummyDummyDummy00flux bootstrap github --token-auth \  --owner=example-org --repository=results-deploy \  --branch=main --path=clusters/prod --personal

Observability: metrics, dashboards, alerts and logs

You can't fix what you can't see. The kube-prometheus-stack chart installs Prometheus (metrics), Alertmanager (alerts) and Grafana (dashboards) with sensible defaults. A ServiceMonitor tells Prometheus which Services to scrape, and a PrometheusRule turns a query into an alert. Ship logs to a central store as well (for example Loki or your cloud's logging service), because a pod's logs disappear with the pod.Source [35]

apiVersion: monitoring.coreos.com/v1kind: ServiceMonitormetadata:  name: results-api  namespace: results  labels:    release: kube-prometheus-stack     # the label the chart's Prometheus selects onspec:  selector:    matchLabels:      app: results-api  endpoints:  - port: http    path: /metrics    interval: 15s---apiVersion: monitoring.coreos.com/v1kind: PrometheusRulemetadata:  name: results-api  namespace: results  labels:    release: kube-prometheus-stackspec:  groups:  - name: results-api    rules:    - alert: ResultsApiHighErrorRate      expr: |        sum(rate(http_requests_total{service="results-api",code=~"5.."}[5m]))          / sum(rate(http_requests_total{service="results-api"}[5m])) > 0.02      for: 5m      labels:        severity: page      annotations:        summary: "More than 2% of results-api requests are failing"

Operators and service meshes

Operators extend Kubernetes with new object types and controllers that know how to run one piece of software well; CloudNativePG above is one, and there are operators for Kafka, Redis, Elasticsearch, certificates (cert-manager) and much more. A service mesh such as Istio or Linkerd adds mutual TLS, retries, timeouts and traffic metrics between services without changing app code. If you turn on retries, cap them with a retry budget: during an outage, unlimited retries multiply the load on the service that is already struggling.Source [36]

11. When a release breaks: debugging by evidence

At 11:00 a new API version goes out and errors climb. Calm beats clever here: gather evidence before changing anything, top to bottom.

kubectl -n results get pods -o wide                              # 1. what state is each pod in?kubectl -n results describe pod results-api-7d9f8-abcde          # 2. read Events at the bottomkubectl -n results logs results-api-7d9f8-abcde                  # 3. current logskubectl -n results logs results-api-7d9f8-abcde --previous       #    logs of the crashed containerkubectl -n results rollout status deployment/results-api         # 4. is the rollout stuck?kubectl -n results get endpointslices -l kubernetes.io/service-name=results-api   # 5. any ready pods behind the Service?kubectl -n results get events --sort-by=.lastTimestamp | tail -20kubectl -n results debug -it results-api-7d9f8-abcde --image=busybox:1.37 --target=api   # a shell next to a distroless containerkubectl top pods -n results                                       # needs metrics-server

Pod state

What it usually means

Look at

Pending

No node has room, or no node matches its rules

describe → Events; requests, quotas, taints, spread rules

ImagePullBackOff

Wrong image name or tag, or missing registry credentials

The image line and imagePullSecrets

CrashLoopBackOff

The app starts and exits again and again

logs --previous; ConfigMaps and Secrets it needs

Running, not Ready

The readiness probe is failing

The /ready endpoint and its dependencies

OOMKilled

It went over its memory limit

The memory limit vs real usage (kubectl top)

If the evidence points at the new version, roll back first and investigate second; the rollout history from section 4 makes that one command.

12. Versions, upgrades, and when not to use Kubernetes

Kubernetes ships three minor versions a year, and each gets about a year of patches. The newest is 1.37, released on 26 August 2026, and 1.34 left support in October 2026. Upgrades are therefore routine work: read the release notes for removed APIs, upgrade the control plane first, one minor version at a time, then the nodes, and let your PodDisruptionBudgets keep apps up during the drains.Source [2]Source [26]

# Control plane first, one minor version at a time, then the nodeskubectl get --raw /versionkubectl api-resources --verbs=list -o name | head        # check for removed APIs before you jumpeksctl upgrade cluster --name results-prod --version 1.37 --approveeksctl upgrade nodegroup --cluster results-prod --name ng-1 --kubernetes-version 1.37# Before draining nodes yourself, make sure every important app has a PodDisruptionBudgetkubectl drain node-3 --ignore-daemonsets --delete-emptydir-datakubectl uncordon node-3

Kubernetes is a powerful tool, not a requirement. A small team with one or two apps may spend more time running the cluster than building the product. Google Cloud Run, AWS Fargate or Azure Container Apps run containers with autoscaling and no cluster to manage, and are often the better first choice. Move to Kubernetes when you have many services, need its scheduling and extension model, or want the same platform across clouds.

Kubernetes in one minute: an audio recap0:55
Transcript
Kubernetes in one minute. You write down what should be true: five copies of this app, on port eighty, with half a CPU each. The control plane stores that in etcd, the scheduler picks a node for every pod, and controllers keep comparing what you asked for with what is running. When a node dies, the pods come back somewhere else. Deployments roll out new versions without dropping traffic. Services give pods a stable name, and Gateway API brings traffic in from the internet. Before a big day, set honest requests and probes, spread pods across zones, and raise the autoscaler's floor early. Lock things down with RBAC, pod security and a policy engine. Around this core sits the ecosystem: Helm to package, Argo CD or Flux to deploy from Git, Prometheus to watch, operators to run databases, and Velero for backups. And when something breaks, collect evidence first: get, describe, logs. Roll back, then find the cause.

Go further

The official Kubernetes documentation covers every object in this post in depth, with tutorials you can run on the kind cluster from section 3:


Describe what should be true, let the control plane decide, let the nodes do it, and prepare the day before. That's Kubernetes, and everything in its ecosystem is a tool for one of those steps.

Sources

  1. Overview, Kubernetes Documentation. Accessed 2026-11-25. Back to the text for source 1
  2. Releases, Kubernetes Documentation. Accessed 2026-11-25. Back to the text for source 2
  3. Controllers, Kubernetes Documentation. Accessed 2026-11-25. Back to the text for source 3
  4. Cluster Architecture, Kubernetes Documentation. Accessed 2026-11-25. Back to the text for source 4
  5. Operating etcd clusters for Kubernetes, Kubernetes Documentation. Accessed 2026-11-25. Back to the text for source 5
  6. kind Quick Start, Kubernetes SIGs (kind). Accessed 2026-11-25. Back to the text for source 6
  7. Production environment, Kubernetes Documentation. Accessed 2026-11-25. Back to the text for source 7
  8. Pods, Kubernetes Documentation. Accessed 2026-11-25. Back to the text for source 8
  9. Taints and Tolerations, Kubernetes Documentation. Accessed 2026-11-25. Back to the text for source 9
  10. Deployments, Kubernetes Documentation. Accessed 2026-11-25. Back to the text for source 10
  11. Pod Lifecycle, Kubernetes Documentation. Accessed 2026-11-25. Back to the text for source 11
  12. Service, Kubernetes Documentation. Accessed 2026-11-25. Back to the text for source 12
  13. Ingress NGINX Retirement: What You Need to Know, Kubernetes Blog (SIG Network and Security Response Committee). Accessed 2026-11-25. Back to the text for source 13
  14. Gateway API, Kubernetes SIG Network. Accessed 2026-11-25. Back to the text for source 14
  15. Network Policies, Kubernetes Documentation. Accessed 2026-11-25. Back to the text for source 15
  16. Encrypting Confidential Data at Rest, Kubernetes Documentation. Accessed 2026-11-25. Back to the text for source 16
  17. External Secrets Operator documentation, External Secrets Operator. Accessed 2026-11-25. Back to the text for source 17
  18. Persistent Volumes, Kubernetes Documentation. Accessed 2026-11-25. Back to the text for source 18
  19. CloudNativePG documentation, CloudNativePG. Accessed 2026-11-25. Back to the text for source 19
  20. Velero documentation, Velero. Accessed 2026-11-25. Back to the text for source 20
  21. Resource Management for Pods and Containers, Kubernetes Documentation. Accessed 2026-11-25. Back to the text for source 21
  22. Configure Liveness, Readiness and Startup Probes, Kubernetes Documentation. Accessed 2026-11-25. Back to the text for source 22
  23. Pod Topology Spread Constraints, Kubernetes Documentation. Accessed 2026-11-25. Back to the text for source 23
  24. Disruptions, Kubernetes Documentation. Accessed 2026-11-25. Back to the text for source 24
  25. Horizontal Pod Autoscaling, Kubernetes Documentation. Accessed 2026-11-25. Back to the text for source 25
  26. Kubernetes v1.37: Garhwal, Kubernetes Blog. Accessed 2026-11-25. Back to the text for source 26
  27. Cron scaler, KEDA. Accessed 2026-11-25. Back to the text for source 27
  28. Prometheus scaler, KEDA. Accessed 2026-11-25. Back to the text for source 28
  29. Using RBAC Authorization, Kubernetes Documentation. Accessed 2026-11-25. Back to the text for source 29
  30. Pod Security Standards, Kubernetes Documentation. Accessed 2026-11-25. Back to the text for source 30
  31. Kyverno documentation, Kyverno. Accessed 2026-11-25. Back to the text for source 31
  32. Helm documentation, Helm. Accessed 2026-11-25. Back to the text for source 32
  33. Argo CD documentation, Argo Project. Accessed 2026-11-25. Back to the text for source 33
  34. Flux documentation, Flux. Accessed 2026-11-25. Back to the text for source 34
  35. Prometheus overview, Prometheus. Accessed 2026-11-25. Back to the text for source 35
  36. Operator pattern, Kubernetes Documentation. Accessed 2026-11-25. Back to the text for source 36