liveBook · Manning

Replica count

As explained in Road to Kubernetes

A replica count is the declared number of Pod instances that a Kubernetes workload should maintain.

A replica count declares how many instances of a workload should run. In a Kubernetes Deployment, it is the desired number of Pods; if omitted, the count defaults to 1. section 8.3.3

Kubernetes treats the count as desired state. Deployments and StatefulSets provision replacement Pods when instances are deleted, fail, or otherwise stop running, keeping the declared total available. section 8.6

Scaling an NGINX Deployment

Set spec.replicas to 15 in a Deployment manifest, apply it with kubectl apply -f my-first-deployment.yaml, and inspect the result with kubectl get deployments or kubectl get pods --selector app=my-nginx. A Service automatically load balances traffic to available, ready Pods. section 8.3.3

Replica counts also appear in Docker Swarm Compose deploy directives, where each service can request a different number of instances. More instances require more cluster compute capacity; ordinary Compose ignores these deploy replicas. section 9.1.2

Replication does not make stateful instances a cluster automatically. StatefulSets pair each declared Pod replica with persistent storage and predictable ordering, but database clustering requires additional work. section 8.4.2

How Road to Kubernetes covers it

How deep it goes
Defines the field, default, reconciliation behavior, and runnable Kubernetes and Swarm examples without exploring scheduler internals.
Examples
Demonstrates 15 NGINX Pods, differentiated Swarm service counts, and a single-replica PostgreSQL StatefulSet.
What it assumes
Assumes basic familiarity with containers and workload manifests while defining Pods, Deployments, and desired state through examples.
What you can do after
Operate/configure workload scale with Kubernetes manifests, kubectl, or Docker Swarm Compose deploy directives.
How it connects
Connects Kubernetes Deployments, Pods, Services, StatefulSets, Docker Swarm, and Docker Compose.

Also explained in

Compare how 2 books explain replica count →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Road to Kubernetes. The section links point to the parts of the book it draws on.