Skip to main content
Intermediate Step-by-Step Tutorial 11 min read Kubernetes 1.30+ / Amazon EKS

Kubernetes Pods, Deployments & Services Explained Clearly

Connect Pods, ReplicaSets, Deployments, readiness probes, and stable ClusterIP Service discovery in clean declarative manifests.

Written by MockAttempt Engineering Editorial Desk (Curriculum & Code Verification Review Panel) Reviewed by Ravi Shankar Mishra
Last updated: Verification Policy

Learning Objectives

  • Explain why bare Pods never self-heal across node failures and why Deployments wrap ReplicaSets.
  • Configure CPU/memory requests & limits alongside distinct readiness and liveness probes.

Prerequisites

  • Docker containers, container ports, and YAML formatting

From Ephemeral Pods to Declarative Deployments

A Kubernetes Pod holds a unique cluster IP while running, yet vanishes permanently if its host node restarts. Creating a Deployment reconciles a ReplicaSet continuously to maintain desired replica count (`replicas: 3`) and performs progressive rolling upgrades without dropping traffic when paired with proper readinessProbe gates.

Learn container optimization in Docker Multi-Stage Builds or explore EKS GitOps in AWS DevOps Career Program.

Practical Programming Examples

Production-Ready Deployment + ClusterIP Service Manifest

Define a 2-replica stateless API Deployment with resource boundaries, readiness probes, and internal ClusterIP service.

Kubernetes 1.30+ Manifest
apiVersion: apps/v1
kind: Deployment
metadata:
  name: courses-api
spec:
  replicas: 2
  selector:
    matchLabels: { app: courses-api }
  template:
    metadata:
      labels: { app: courses-api }
    spec:
      containers:
        - name: api
          image: ghcr.io/mockattempt/courses-api:1.4.0
          ports: [{ containerPort: 8080 }]
          readinessProbe:
            httpGet: { path: /healthz, port: 8080 }
            initialDelaySeconds: 5
          resources:
            requests: { cpu: 100m, memory: 128Mi }
            limits: { cpu: 500m, memory: 256Mi }
---
apiVersion: v1
kind: Service
metadata:
  name: courses-api-svc
spec:
  type: ClusterIP
  selector: { app: courses-api }
  ports: [{ port: 80, targetPort: 8080 }]
Expected Output
Deployment schedules 2 healthy pods behind stable internal DNS `courses-api-svc:80`.
Step-by-Step Execution
  1. Label selector `app: courses-api` ties Service endpoints dynamically to matching Ready Pods.
  2. `readinessProbe` prevents kube-proxy from sending user requests before `/healthz` reports HTTP 200.

Common Mistakes to Avoid

  • Deploying `:latest` mutable image tags instead of pinned semantic/SHA digests.
  • Omitting `resources.requests` / `limits`, letting noisy containers trigger cluster node OOM eviction.

Production Best Practices

  • Separate fast `/healthz` readiness checks from heavy downstream dependency checks inside `/ready`.
  • Pair Deployments with HorizontalPodAutoscaler (HPA) and PodDisruptionBudget (PDB) in multi-AZ clusters.

Technical Interview Relevance

Core Kubernetes troubleshooting interview scenario (CrashLoopBackOff, ImagePullBackOff, Pod pending diagnostics).

Practice & Self-Check Questions

Why does a Service still maintain a stable IP and DNS name even when Pods restart continuously?

Kubernetes decouples network identity (Service ClusterIP + CoreDNS record) from dynamic Pod endpoints updated by EndpointSlices whenever Pods pass readiness checks.

Optional Next Step

Have Questions About Learning Kubernetes Structured Cohorts?

Request the AWS-DOP-C02 syllabus & weekend batch schedule from an Academic Counselor.

View AWS-DOP-C02 Details →
Learn. Practise. Prove. Get Career-Ready.

Ready to Build Your IT Career?

Explore industry-led programmes and develop practical skills through training, assessments and interview preparation.