Skip to content

Chapter 9: Cloud Native Architecture

Cloud-native applications are designed to exploit cloud infrastructure: they are containerized, dynamically orchestrated, and oriented around services. The key shift is in the question you ask. Instead of “how do I keep this server running?”, you ask “how do I make the system resilient when servers fail?” That means designing for failure, automation, and horizontal scaling from the start rather than bolting them on later.

Concepts from other sections (6)

This section uses these ideas. Each has a short definition and a link to the section that explains it in full. Tap a dotted term in the text to preview it.

  • Horizontal scaling: adding capacity by adding machines; more complex but effectively unlimited, and it suits stateless services. Read more: Chapter 1: System Design
  • Twelve-Factor App: a set of principles that make a service orchestratable: config from the environment, stateless processes, logs to stdout, strict build/run separation, and disposability (fast startup, graceful shutdown). Read more: Chapter 10: Kubernetes Workloads and Deployment
  • multi-stage build: a Dockerfile with several FROM stages, where only the last stage ships. Read more: 1.7 Containers and Kubernetes: images, layers, Pods, Deployments, Services, Helm, kind in Programming and Algorithms
  • Control plane: the API server, etcd, scheduler, and controller manager, which store desired state and decide what should run where; worker nodes carry out those decisions. Read more: Chapter 10: Kubernetes Workloads and Deployment
  • Pull request (PR): a proposed change, made of a branch, a description, and a diff against a base branch. Read more: 6.2 Code review in Software Engineering
  • Exponential backoff: a retry delay that grows by a constant factor per failure, up to a cap. Read more: 7.5 Activities

This chapter builds the vocabulary from the bottom up. It starts with containers and images, moves to the Kubernetes objects that run them and the reconciliation model behind those objects, then to packaging and deployment with Helm, GitOps, and CI/CD pipelines, and finally to the networking and resilience patterns that keep a distributed system standing. Kubernetes is the orchestration standard, but understanding the concepts matters far more than memorizing YAML, and the Twelve-Factor App principles apply whether you run on Kubernetes, ECS, or bare metal.

Learning objectives

  • Build small, secure container images and explain the build/run separation.
  • Describe the core and advanced Kubernetes objects and the desired-state reconciliation model.
  • Explain how Helm and GitOps make deployments auditable, reviewable, and reversible.
  • Compare canary, blue-green, and feature-flag release strategies.
  • Apply circuit breakers, bulkheads, retries with backoff, sidecars, ambassadors, and the strangler fig to concrete failure problems.

You need Linux basics and the concept of a container. If containers are new to you, read Containers and Kubernetes in Programming and Algorithms first. Continue with Chapter 10, Kubernetes Workloads and Deployment, to apply these principles to a running platform.

A container image is a stack of immutable layers; a container is a running instance of an image; a Dockerfile holds the build instructions. Multi-stage builds keep the final image small by leaving build tools behind, and security scanning checks the result. Underneath this is a Twelve-Factor principle: strict separation between the build stage and the run stage.

A few practices pay for themselves every time. Run one process per container. Pin base image versions. Do not run as root. Use .dockerignore. And order layers deliberately, because layer ordering decides how often the build cache hits.

A Pod is the smallest deployable unit. A Deployment declares a desired state for a set of Pods and performs rolling updates toward it. A Service gives Pods stable networking, as ClusterIP, NodePort, or LoadBalancer. ConfigMaps and Secrets externalize configuration, and Namespaces provide isolation.

The mental model that ties these together is reconciliation: you declare the desired state in YAML, and the control plane continuously moves the actual state toward it. Every object above is a statement of what should be true, not a command to do something once.

The same model extends to harder workloads. StatefulSets give Pods stable network identities, which databases need. DaemonSets run one Pod per node, for agents. Jobs and CronJobs handle batch and scheduled work. RBAC controls who can do what, and Network Policies act as a pod-to-pod firewall. Finally, CRDs and Operators extend Kubernetes itself with custom resources and the controllers that reconcile them.

Helm charts are templated Kubernetes manifests with versioned releases, configured through values.yaml. GitOps goes one step further: a tool such as ArgoCD or Flux watches a git repository and syncs the cluster to it, so git becomes the source of truth for infrastructure. The payoff is that infrastructure inherits git’s workflow: an audit trail (git log), rollback (git revert), and review (pull requests for infrastructure changes). GitOps is the modern deployment standard for exactly this reason.

A pipeline, whether in GitHub Actions, GitLab CI, or Jenkins, runs the same sequence: build, test, scan, push the image, deploy. How the new version reaches users is a separate choice. A canary deployment routes a small percentage of traffic to the new version first. A blue-green deployment switches all traffic at once between two complete environments. Feature flags decouple deploying code from releasing behavior, so a deploy can ship dark and be turned on later.

A service mesh such as Istio or Linkerd puts a sidecar proxy next to each service. The proxies handle mTLS, traffic management, and observability with no code changes: service-to-service encryption, circuit breaking, traffic splitting, and distributed tracing. The cost is operational. On small clusters, or wherever the overhead exceeds the benefit, do not use one.

Most resilience problems in a distributed system have a named pattern. The following table pairs each problem with its pattern and the solution it applies.

PatternProblemSolution
Circuit breakerCascading failuresStop calling a failing service; fail fast
BulkheadOne component failure takes down everythingIsolate resources per component
Retry with backoffTransient failuresRetry with exponential backoff + jitter
SidecarCross-cutting concerns (logging, auth)Attach helper container to each pod
AmbassadorService discovery complexityLocal proxy handles routing
Strangler figMigrating from monolithGradually route traffic to new service

How large companies run their infrastructure shows these ideas at scale. The following table summarizes a few.

CompanyInfrastructureFocus
GoogleGKE, Borg (predecessor to Kubernetes)Kubernetes was built here
AmazonEKS, ECS, LambdaMulti-orchestration, serverless
NetflixSpinnaker, Titus (custom on EC2)Deployment tooling, resilience
AnthropicKubernetes + GPU orchestrationInference serving at scale
StripeKubernetes for backend servicesReliable deployments, zero downtime
  • Cloud native means designing for failure, automation, and horizontal scaling from the start.
  • Kubernetes objects declare desired state; the control plane reconciles actual state toward it.
  • Helm packages manifests; GitOps makes git the source of truth, giving deployments an audit trail, rollback, and review.
  • Canaries, blue-green switches, and feature flags are different answers to how a new version reaches users.
  • Named cloud patterns (circuit breaker, bulkhead, retry with backoff, sidecar, ambassador, strangler fig) address specific failure problems.
  • DaemonSet: a Kubernetes object that runs one Pod on every node, used for per-node agents such as log shippers and monitoring.
  • Custom resource definition (CRD): a schema that adds a new resource type to the Kubernetes API, so the cluster can store and serve objects of that kind.
  • Kubernetes Operator: a controller that reconciles custom resources, encoding the operational knowledge of running a particular system (such as a database) in software.
  • GitOps: a deployment model in which a tool such as Argo CD or Flux syncs a cluster to a git repository, making git the source of truth so infrastructure changes get an audit trail, review, and rollback by revert.
  • Blue-green deployment: running two complete environments and switching all traffic from the old (blue) to the new (green) at once, which makes rollback a switch back.
  • Feature flag: a runtime switch that turns behavior on or off without a deploy, decoupling deploying code from releasing it.
  • Service mesh: a layer of sidecar proxies, as in Istio or Linkerd, that handles mTLS, traffic splitting, circuit breaking, and tracing between services with no application changes, at an operational cost.
  • Circuit breaker: a wrapper that stops calling a failing dependency after repeated errors and fails fast for a while, preventing cascading failures and giving the dependency time to recover.
  • Bulkhead pattern: isolating resources (pools, connections, threads) per component so one component’s failure or overload cannot exhaust what others need.
  • Sidecar pattern: attaching a helper container to each pod to handle a cross-cutting concern such as logging, proxying, or auth beside the main container.
  • Ambassador pattern: a local proxy beside a service that handles routing and service discovery to remote services on its behalf.
  • Strangler fig: migrating away from a monolith by gradually routing more traffic to new services until the old system can be removed.