Roadmap › Kubernetes (K8s) & AKS › Module: Architecture and Core Objects
Lessons in this course (15)

2. Pods, ReplicaSets and Deployments

Basic★ Must knowLesson 2 of 15
  • Pod — smallest deployable unit: one or more containers sharing network (same IP, localhost) and volumes. Pods are ephemeral — never manage them directly in production.
  • ReplicaSet — keeps N identical pods running.
  • Deployment — manages ReplicaSets for stateless apps; adds rolling updates, rollbacks and history.
yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: shop-api
  labels: { app: shop-api }
spec:
  replicas: 3
  selector:
    matchLabels: { app: shop-api }
  strategy:
    type: RollingUpdate
    rollingUpdate: { maxSurge: 1, maxUnavailable: 0 }
  template:
    metadata:
      labels: { app: shop-api }
    spec:
      containers:
        - name: api
          image: myacr.azurecr.io/shop-api:1.4.2
          ports:
            - containerPort: 8080
          env:
            - name: ASPNETCORE_ENVIRONMENT
              value: Production
          resources:
            requests: { cpu: 250m, memory: 256Mi }
            limits:   { memory: 512Mi }
          readinessProbe:
            httpGet: { path: /health/ready, port: 8080 }
            initialDelaySeconds: 5
            periodSeconds: 10
          livenessProbe:
            httpGet: { path: /health/live, port: 8080 }
            periodSeconds: 15
            failureThreshold: 3

Labels (key/value tags) + selectors connect objects: the Deployment selects its pods, a Service selects pods to route to.