...

/

ReplicaSets and Scaling

ReplicaSets and Scaling

Learn how Deployments offer self-healing and scalability.

Deployments and ReplicaSets

We’ve repeatedly said that Deployments add self-healing, scaling, rollouts, and rollbacks. However, behind the scenes, it’s actually a different resource called a ReplicaSet that provides self-healing and scaling.

The following figure shows the overall architecture of containers, Pods, ReplicaSets, and Deployments. It also shows how they map into a Deployment YAML.

Press + to interact
Architecture
Architecture

Posting this Deployment YAML to the cluster will create a Deployment, a ReplicaSet, and two identical Pods running identical containers. The Pods are managed by the ReplicaSet, which, in turn, is managed by the Deployment. We should then perform all management via the Deployment and never directly manage the ReplicaSet or Pods.

A quick word on scaling

It’s possible to scale our apps manually, and we’ll see how to do that shortly. However, Kubernetes has several autoscalers that automatically scale our apps and infrastructure. Some of them include:

  • The Horizontal Pod Autoscaler

  • The Vertical Pod Autoscaler

  • The Cluster Autoscaler

The Horizontal Pod Autoscaler (HPA) adds and removes Pods to meet current demand. Most clusters install it by default, and it’s widely used.

The Cluster Autoscaler (CA) adds and ...