liveBook · Manning

ReplicaSet

As explained in Kubernetes for Developers

A ReplicaSet is a Kubernetes workload resource that maintains a set of Pods matching a specified Pod template and replica count.

A ReplicaSet is a Kubernetes workload resource that manages a set of Pods from a Pod template and replica count. Deployments create ReplicaSets behind the scenes, normally hiding this implementation detail. section 12.5.1

During a rolling update, a Deployment uses separate ReplicaSets for the old and new versions, scaling them gradually to replace Pods. section 12.5.1

Find rejected Pods through the ReplicaSet

If a Deployment reports no Pods, inspect its ReplicaSet. Commands such as kubectl get rs and kubectl describe rs can reveal FailedCreate events and admission errors that are not visible on the Deployment itself. section 12.5.1

$ kubectl create -f Chapter03/3.2_DeployingToKubernetes/deploy.yaml
deployment.apps/timeserver created
 
$ kubectl get deploy
NAME         READY   UP-TO-DATE   AVAILABLE   AGE
timeserver   0/3     0            0           12s
 
$ kubectl get pods
No resources found in myapp namespace.
$ kubectl get rs
NAME                   DESIRED   CURRENT   READY   AGE
timeserver-5b4fc5bb4   3         0         0       31s
 
$ kubectl describe rs
Events:
  Type     Reason        Age                  From                   Message
  ----     ------        ----                 ----                   -------
  Warning FailedCreate 36s             replicaset-controller
  Error creating: admission webhook "pod-security-webhook.kubernetes.io"
  denied the request: pods "timeserver-5b4fc5bb4-hvqcm" is forbidden:
  violates PodSecurity "restricted:v1.28": allowPrivilegeEscalation != false
  (container "timeserver-container" must set
  securityContext.allowPrivilegeEscalation=false), unrestricted capabilities
  (container "timeserver-container" must set
  securityContext.capabilities.drop=["ALL"]), runAsNonRoot != true (pod or
  container "timeserver-container" must set
  securityContext.runAsNonRoot=true)

Shows a Deployment with zero Pods and the ReplicaSet event containing the rejected-Pod admission error. section 12.5.1

How Kubernetes for Developers covers it

How deep it goes
Explains Pod management, rolling-update versioning, and admission-error inspection without developing a standalone ReplicaSet API.
Examples
Uses kubectl get rs, kubectl describe rs, and a Deployment whose Pods are rejected by Pod Security admission.
What you can do after
Diagnose missing Deployment Pods by inspecting ReplicaSet status and events with kubectl.
How it connects
Connects ReplicaSets to Pods, Deployments, rolling updates, and Pod Security admission.

Also explained in

Compare how 5 books explain ReplicaSet →

Related concepts

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