liveBook · Manning

Replica

As explained in Learn Docker in a Month of Lunches, Second Edition

A replica is an independently running instance of a workload maintained to provide capacity or redundancy.

A replica is an independently running instance of a workload. In Kubernetes, a Deployment uses its replica count to maintain the desired number of Pods, providing capacity and redundancy. section 15.3

Increasing replicas lets multiple Pods serve traffic. If one fails, the remaining Pods can continue serving requests while the Deployment creates a replacement. A Service distributes requests across matching Pods. section 15.3

Scale an application to three replicas

Run `kubectl scale deploy/numbers-api --replicas 3`, then inspect the matching Pods and Service endpoints. Repeated requests are distributed across the Pods, while a failed Pod can be replaced. section 15.3

Listing 15.4 Deployment spec that includes the templated Pod spec
apiVersion: v1 
kind: Deployment
metadata:
  name: numbers-api
spec:                   # this is the Deployment spec
  replicas: 1           # the number of Pods to create
  selector:             # selector to find Pods
    matchLabels:
      app: numbers
      component: api
  template:             # this is the template for creating Pods
    metadata:
      labels:           # labels the Deployment selector uses
        app: numbers
        component: api
    spec:               # and this is the Pod spec
      containers:
        - name: api     # full container spec snipped

Inspect the Deployment template and its `replicas` field alongside the labels that select the managed Pods. section 15.3

How Learn Docker in a Month of Lunches, Second Edition covers it

How deep it goes
Explains replica counts, Pod replacement, Service distribution, and health probes, but stops short of controller internals.
Examples
Demonstrates scaling `numbers-api` to three Pods, inspecting endpoints, sending requests, and configuring readiness and liveness probes.
What it assumes
Assumes familiarity with Kubernetes Deployments, Pods, Services, selectors, and labels.
What you can do after
Operate/configure a Deployment by changing its replica count and verifying Pods and Service endpoints with kubectl.
How it connects
Connects replicas with Deployments, Pods, Services, labels, traffic distribution, and health checks.

Also explained in

Compare how 12 books explain replica →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Docker in a Month of Lunches, Second Edition. The section links point to the parts of the book it draws on.