🎓 A1Learner
🔍
0 of 51 lessons completed

Kubernetes: ReplicaSets, Plainly

A ReplicaSet is an object that keeps a stated number of identical Pods running. A Deployment owns a ReplicaSet, and the ReplicaSet does the counting.

See the counting object

One ReplicaSet holds three Pods. Desired, current and ready all read 3.

kubectl get replicasets

The Deployment sits above it

The Deployment is the owner. It tells the ReplicaSet what to run and how many.

kubectl get deployments

The count heals itself

Delete a Pod and the ReplicaSet starts a new one. The Deployment never needs to act.

kubectl delete pod web-6d9f8b7c4d-abc12

Example

kubectl get replicasets
kubectl get pods

Key points

  • ReplicaSet: the object that owns a set of identical Pods and keeps their count steady.
  • A Deployment creates a ReplicaSet when you create the Deployment.
  • The ReplicaSet creates Pods and replaces any Pod that dies.
  • A new ReplicaSet appears when you update the image, and the old one scales to zero.
  • Use kubectl get replicasets to see the ReplicaSets in a namespace.
  • You almost never create a ReplicaSet by hand.

In this example, get replicasets shows one ReplicaSet with 3 of 3 replicas ready. get pods shows the three Pods it owns. The Deployment created the ReplicaSet, and the ReplicaSet counted the Pods.

Note

A ReplicaSet name is the Deployment name plus a short hash, and Pod names add one more short ending.

Try it Yourself

Edit the code, then press Run.

Running is simulated · Rust Playground

Exercise

What does a ReplicaSet do inside a Deployment?