Volume 4 · Chapter 6 — Compute and Containers
Kubernetes Core Objects
6.1 Introduction
If you run containers on EKS, you work with Kubernetes objects, and interviews for container-based roles routinely probe the core ones: Pods, Deployments, ReplicaSets, Services, and Ingress. These objects express the same reliability and scaling ideas seen throughout this volume - desired state, self-healing, load distribution - in Kubernetes’ declarative model. This chapter explains each and how they fit together to run a resilient, scalable service.
6.2 Pods
A Pod is the smallest deployable unit in Kubernetes - it wraps one container (or occasionally a few tightly coupled containers that must run together) plus its shared networking and storage. Containers don’t run directly in Kubernetes; they run inside Pods. Pods are designed to be ephemeral and disposable: they can be created and destroyed freely, they get their own internal IP, and you don’t nurse an individual Pod - if one dies, it’s replaced by a new one rather than repaired. Because Pods come and go and their IPs change, you never rely on a specific Pod or its address directly; you rely on higher-level objects that manage Pods and provide stable access to them. This disposability is the container-level version of “cattle, not pets.”
6.3 Deployments and ReplicaSets
You rarely create Pods directly; you declare a Deployment. A Deployment expresses the desired state for your application - which container image to run and how many replicas (identical Pods) you want - and Kubernetes continuously works to make reality match that declaration. Under the hood a Deployment manages a ReplicaSet, whose job is to ensure the specified number of Pod replicas are always running: if a Pod dies, the ReplicaSet creates a new one to maintain the count (self-healing); if you change the desired count, it adds or removes Pods (scaling). The Deployment adds update capabilities on top - notably rolling updates and rollbacks (next chapter). So the hierarchy is: you declare a Deployment, it manages a ReplicaSet, and the ReplicaSet keeps the right number of Pods running - the declarative, self-healing core of Kubernetes.
flowchart TB Dep[Deployment - desired state: image + replica count] --> RS[ReplicaSet - maintains N replicas] RS --> P1[Pod] RS --> P2[Pod] RS --> P3[Pod] P1 -.dies.-> RS RS -.creates replacement.-> P4[Pod new] Svc[Service - stable endpoint] --> P1 & P2 & P3
6.4 Services
Because Pods are ephemeral with changing IPs, you need a stable way to reach them - that’s a Service. A Service provides a stable network endpoint and a consistent name for a set of Pods, and load-balances traffic across the healthy Pods behind it, automatically tracking which Pods currently exist. So other components connect to the Service, not to individual Pods, and the Service routes to whatever Pods are running - giving stable service discovery and load balancing even as Pods come and go underneath. Services come in types for different exposure: an internal cluster-only endpoint for service-to-service communication, or types that expose the service outside the cluster (often paired with a load balancer). The Service is what turns a shifting set of disposable Pods into a dependable, addressable service.
6.5 Ingress
Ingress manages external HTTP/HTTPS access into the cluster, acting as a smart entry point that routes incoming requests to the right Service based on rules - typically the host or URL path. Instead of exposing each Service separately, you define Ingress rules like “requests for /payments go to the payments Service, /accounts to the accounts Service,” and an ingress controller (often backed by a load balancer) enforces them, commonly also terminating TLS. This is the Kubernetes equivalent of the application-layer routing an Application Load Balancer provides - a single, controlled front door that directs external traffic to the appropriate internal Services by path or host, which is ideal for exposing multiple microservices behind one entry point.
6.6 Banking Production Scenario
A bank runs each microservice on EKS as a Deployment specifying the service’s versioned image and a replica count, spread across Availability Zones. Each Deployment’s ReplicaSet keeps the desired number of Pods running, replacing any that fail - self-healing without intervention. Each microservice is fronted by a Service that gives it a stable internal endpoint and load-balances across its Pods, so services address each other by stable name regardless of Pod churn. An Ingress provides the single external front door, routing customer traffic by path to the right Service (payments, accounts, transfers) and terminating TLS. Scaling a service is a matter of raising its replica count or letting autoscaling do it, and the declarative model means the running state always converges to what’s declared.
6.7 Troubleshooting: Kubernetes Object Issues
Kubernetes issues map to these objects. Pods stuck pending mean they can’t be scheduled - usually insufficient cluster capacity (add nodes or use Fargate). Pods crash-looping mean the container is failing on startup or its health check - inspect Pod logs and configuration. A Deployment not reaching the desired replica count points to Pods failing to become healthy. If a service is unreachable, the Service may not be selecting the right Pods (label mismatch) or the Pods aren’t healthy. If external traffic can’t get in, the Ingress rules, controller, or TLS configuration need checking. Because everything is declarative, a powerful technique is comparing declared desired state with actual state - Kubernetes reports why they differ. The diagnostic flow is Pods (are they running and healthy?), then the controlling Deployment/ReplicaSet, then the Service (does it select healthy Pods?), then Ingress (external routing).
Explain Pods, Deployments, ReplicaSets, Services, and Ingress and how they work together.
These are the core Kubernetes objects, and they fit together to run a resilient, scalable, accessible service using Kubernetes’ declarative, self-healing model. A Pod is the smallest deployable unit - it wraps one container (or a few tightly-coupled ones) with shared networking and storage; containers run inside Pods, not directly. Pods are ephemeral and disposable: they’re created and destroyed freely, get their own changing IP, and aren’t repaired individually - if a Pod dies it’s replaced, which is “cattle, not pets” at the container level, and it means you never depend on a specific Pod or its address. You rarely create Pods directly; instead you declare a Deployment, which expresses the desired state for your application - which container image and how many replicas you want - and Kubernetes continuously reconciles reality to match it. The Deployment manages a ReplicaSet, whose single job is to keep the specified number of Pod replicas running: if a Pod dies, the ReplicaSet creates a replacement to maintain the count, giving self-healing, and if you change the desired count it adds or removes Pods, giving scaling. The Deployment adds update capabilities on top, like rolling updates and rollbacks. So the chain is: you declare a Deployment, it manages a ReplicaSet, and the ReplicaSet maintains the Pods. Because Pods are ephemeral with shifting IPs, you need a stable way to reach them, which is a Service: it provides a stable endpoint and consistent name for a set of Pods and load-balances across the healthy ones, automatically tracking which Pods exist - so other components talk to the Service, not to individual Pods, giving stable discovery and load balancing despite Pod churn. Finally, Ingress manages external HTTP/HTTPS access into the cluster, acting as a smart front door that routes incoming requests to the right Service by host or path - “/payments to the payments Service” - usually via an ingress controller backed by a load balancer that also terminates TLS, which is how you expose multiple microservices behind one controlled entry point. Put together: a Deployment declares the desired image and replica count, its ReplicaSet keeps that many self-healing Pods running, a Service gives those Pods a stable address and load-balances across them, and Ingress routes external traffic to the right Service - the whole system continuously converging on the declared state, which is what makes Kubernetes a self-healing, scalable, declaratively-managed platform.
Chapter Revision Notes
- Pod: smallest unit, wraps container(s) with shared network/storage; ephemeral and disposable - never depend on a specific Pod.
- Deployment: declares desired state (image + replica count); manages a ReplicaSet and adds rolling updates/rollbacks.
- ReplicaSet: keeps the desired number of Pod replicas running - self-healing (replace failures) and scaling (change count).
- Service: stable endpoint and name for a set of Pods, load-balancing across healthy ones despite Pod churn.
- Ingress: smart external HTTP/HTTPS front door routing to Services by host/path, often terminating TLS.