Replicasets

🚀 What It Does

The main goal of a ReplicaSet is to maintain pod availability — if a pod crashes or is deleted, the ReplicaSet automatically creates a new one to replace it.

Whilst you can use ReplicaSets directly, they are most commonly used indirectly through Deployments, which provide additional features like rolling updates and rollbacks.

🧩 Key Components

The key components of a ReplicaSet include:

  • Selector: Defines how the ReplicaSet finds which pods to manage, usually via labels.
  • Replicas: Specifies the desired number of pod copies.
  • Template: Describes the pod configuration (e.g., container image, ports, environment variables).

⚙️ How It Works

  1. You define a ReplicaSet in a YAML or JSON manifest.
  2. Kubernetes uses the selector to match existing pods.
  3. If the number of matching pods is less than desired, it creates more; if more exist, it deletes the extras.

Kubernetes ReplicaSet Kubernetes ReplicaSet