Software Engineering

Kubernetes: Why Containers Changed Software Deployment

Six years after Google open-sourced it, Kubernetes has become the default platform for running containers in production. We explain what problem containers solved, why an orchestrator was needed on top, and how Kubernetes' declarative model changed the way teams deploy software.

By EthicalHat Research · · 3 min read
Infographic: From 'works on my machine' to declarative deployment

"It works on my machine" used to be the most common phrase in software delivery. Code that ran perfectly on a developer's laptop failed in testing because of a different library version, and failed again in production because of a different operating system patch. Deployment meant runbooks, configuration management scripts and long evenings.

Two technologies changed that in a remarkably short time: containers, popularised by Docker in 2013, and Kubernetes, open-sourced by Google in 2014.

What containers solved

A container packages an application together with everything it needs to run: its runtime, libraries and configuration. It uses Linux kernel features (namespaces and cgroups) to isolate processes, without the overhead of a full virtual machine.

The key properties:

  • Consistency. The same image runs on a laptop, in CI and in production.
  • Speed. Containers start in seconds, not minutes.
  • Density. Many containers share one host kernel, so you can pack more workloads per server.
  • Immutability. You do not patch a running container; you build a new image and replace it.

A simple Dockerfile captures the whole runtime environment in a few lines:

dockerfile
FROM python:3.8-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
USER 1000
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "app:app"]

Why containers needed an orchestrator

Running one container is easy. Running hundreds across dozens of servers raises harder questions:

  • Which server should each container run on?
  • What happens when a server dies?
  • How do containers find each other?
  • How do you roll out a new version without downtime, and roll back if it breaks?
  • How do you scale up when traffic grows?

Kubernetes answers all of these. It grew out of Google's experience running its internal cluster manager, Borg, for more than a decade, and it reached version 1.0 in 2015 alongside the founding of the Cloud Native Computing Foundation.

The big idea: desired state

The most important thing about Kubernetes is not any single feature. It is the model. Instead of telling the system what to do ("start three containers on these servers"), you declare what you want ("there should always be three replicas of this application"), and Kubernetes continuously works to make reality match.

yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
spec:
  replicas: 3
  selector:
    matchLabels: { app: web }
  template:
    metadata:
      labels: { app: web }
    spec:
      containers:
        - name: web
          image: registry.example.com/web:1.4.2
          ports: [{ containerPort: 8000 }]
          readinessProbe:
            httpGet: { path: /healthz, port: 8000 }

Controllers inside Kubernetes run reconciliation loops: observe the current state, compare it with the desired state, act to close the gap, and repeat.

flowchart LR
  D[Desired state<br/>replicas: 3] --> C{Controller<br/>compares}
  A[Actual state<br/>2 pods running] --> C
  C -->|difference| X[Start 1 pod]
  X --> A

If a server fails and takes a pod with it, nobody has to be paged to restart it. The controller sees two replicas instead of three and schedules a new one. Rolling updates, autoscaling and self-healing all follow from the same idea.

What changed for teams

  • Deployments became routine. Changing an image tag and applying a manifest triggers a rolling update with health checks. Rollback is one command.
  • Infrastructure became code. Manifests live in version control, are reviewed like code, and describe the whole application.
  • Portability improved. The same manifests run on AWS, Azure, Google Cloud or on-premises clusters.
  • A common platform emerged. Logging, monitoring, networking and security tools now target Kubernetes as a standard platform, which has created a huge ecosystem.

The honest downside

Kubernetes is powerful, and powerful systems are complex. Running your own control plane, networking, storage, upgrades and security is a significant engineering commitment. Common pitfalls include:

  • adopting Kubernetes for a handful of services that a simpler platform would serve better,
  • skipping resource limits, health probes and security contexts,
  • underestimating upgrades (Kubernetes releases a new minor version several times a year), and
  • leaving clusters with insecure defaults.

For most organisations, a managed Kubernetes service (EKS, AKS or GKE) removes the hardest operational work, and a small platform team can provide sensible defaults and templates for everyone else.

Is it right for you?

Kubernetes is a good fit when you run many services, need frequent deployments, and have (or can build) the skills to operate it. If you run a single web application, a platform-as-a-service or serverless offering may get you most of the benefits with far less to manage.

Either way, the ideas Kubernetes popularised (immutable images, declarative configuration and automated reconciliation) are worth adopting wherever you run software.

Our secure SDLC team builds cloud-native applications on Kubernetes, and our Kubernetes security checks that clusters are production-ready.

EthicalHat Research

The EthicalHat research team: penetration testers, SOC analysts and engineers writing about security, software engineering and AI.

Want an expert opinion on your own systems?

Email info@ethicalhat.com or call +1-844-838-4422. Our security engineers are happy to talk it through.