liveBook · Manning

Replica

As explained in Acing the Certified Kubernetes Administrator Exam, Second Edition

A replica is an independently running copy of a pod or application instance that contributes to workload capacity and redundancy.

A replica is an independently running copy of a pod or application instance. Multiple replicas provide workload capacity, redundancy, and fault tolerance when one pod is unavailable. Kubernetes commonly manages replicas through a Deployment and its ReplicaSet. section 5.1.1

Use replicas to:

  • Run multiple copies of a stateless application so requests receive the same response from any instance. section 5.1.1
  • Increase or decrease application capacity by scaling a Deployment. section 5.1.1
  • Improve DNS query performance by scaling CoreDNS replicas. section 6.2.3
  • Recognize pods belonging to the same Deployment by their shared prefix and unique hash suffix. section 5.1.1

Scale and update an Apache Deployment

Create three replicas with `kubectl create deploy apache --image httpd:2.4.65 --replicas 3`. Verify them with `kubectl get deploy`, scale to five with `kubectl scale deploy apache --replicas 5`, and verify the five running pods with `kubectl get po`. Change the image using `kubectl set image deploy apache httpd=httpd:alpine`, then inspect the newly created pods. section 5.1.1

root@kind-control-plane:/# kubectl -n kube-system get po
NAME                                         READY   STATUS    
 RESTARTS      AGE
coredns-565d847f94-4pnf4                     1/1     Running   
 0             143m
coredns-565d847f94-xstnx                     1/1     Running   
 0             143m
etcd-kind-control-plane                      1/1     Running   
 0             143m
kindnet-75z9k                                1/1     Running   
 3 (46m ago)   143m
kube-apiserver-kind-control-plane            1/1     Running   
 0             94m
kube-controller-manager-kind-control-plane   1/1     Running   
 1 (95m ago)   143m
kube-proxy-s5vps                             1/1     Running   
 0             143m
kube-scheduler-kind-control-plane            1/1     Running   
 1 (95m ago)   143m

Inspect CoreDNS replicas, scale them from two to three, and observe how scaling them to zero removes cluster DNS resolution. section 6.2.3

How Acing the Certified Kubernetes Administrator Exam, Second Edition covers it

How deep it goes
Explains kubectl scaling, pod naming, stateless behavior, and DNS failure through operational examples.
Examples
Demonstrates Apache replicas, CoreDNS scaling, pod listings, image replacement, Service access, and DNS failure.
What it assumes
Builds from Pods and their ephemeral nature while assuming basic kubectl and Kubernetes cluster access.
What you can do after
Operate/configure Deployment replicas with kubectl and verify resulting pods, images, and DNS availability.
How it connects
Connects replicas with Pods, Deployments, ReplicaSets, Services, stateless applications, and DNS.

Also explained in

Compare how 12 books explain replica →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Acing the Certified Kubernetes Administrator Exam, Second Edition. The section links point to the parts of the book it draws on.