liveBook · Manning

Pod

As explained in Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform

A Kubernetes Pod is the smallest deployable unit in Kubernetes, consisting of one or more co-located containers that share network and storage resources.

A pod is Kubernetes’ basic unit of computation. Nodes host pods, and pods host containers. A pod can contain multiple containers, but a straightforward microservice deployment uses one container per pod. That simplification is useful here; a pod and a container are not the same thing. section 6.4.2

For a running microservice, put the pod under a Deployment rather than creating it alone. The Deployment monitors the workload and replaces its pod if the microservice crashes or stops responding. A Service supplies a DNS record so the microservice can be reached. One pod is enough for the initial setup; multiple replicas are a later route to redundancy and load balancing. section 6.4.3

Listing 6.2 Deploying our microservice to Kubernetes on Azure
apiVersion: apps/v1
kind: Deployment
metadata:
  name: video-streaming
spec:
  replicas: 1
  selector:
    matchLabels:
      app: video-streaming
  template:
    metadata:
      labels:
        app: video-streaming
    spec:
      containers: 
      - name: video-streaming
        image: bmdk1.azurecr.io/video-streaming:1   #1
        imagePullPolicy: IfNotPresent               #2
        env:
        - name: PORT
          value: "4000"
---
apiVersion: v1
kind: Service
metadata:
  name: video-streaming
spec:
  selector:
    app: video-streaming
  type: LoadBalancer                                #3
  ports:
    - protocol: TCP
      port: 80
      targetPort: 4000

The deployment manifest puts the container image and PORT setting inside the pod template, sets one replica, and uses matching app labels to connect the Deployment and Service. This version pulls its image from a container registry and exposes the Service through an Azure load balancer. section 6.11.4 section 6.8.3

Check a local deployment

With Docker Desktop Kubernetes enabled and kubectl connected to its context, run `kubectl apply -f scripts/deploy.yaml`. Then run `kubectl get pods`, `kubectl get deployments`, and `kubectl get services`. The single-replica example produces one running pod alongside its Deployment and Service. Its pod name begins with the microservice name and has a Kubernetes-generated suffix. When finished, run `kubectl delete -f scripts/deploy.yaml` and repeat the checks to confirm cleanup. section 6.8.4 section 6.8.5 section 6.8.7

How Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform covers it

How deep it goes
Explains pod placement, single-container setup, Deployment replacement, and YAML pod templates; defers detailed scaling and redundancy.
Examples
Uses a one-replica microservice manifest and kubectl output showing its running pod, Deployment, and Service.
What it assumes
Assumes a built microservice image while showing how to connect kubectl to a Docker Desktop Kubernetes cluster.
What you can do after
Operate/configure a pod through a Deployment manifest, verify it with kubectl, and remove the configuration after testing.
How it connects
Connects pods to nodes, containers, Deployments, Services, labels, and replicas.

Also explained in

Compare how 15 books explain pod →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform. The section links point to the parts of the book it draws on.