Skip to main content
Kubernetes controllers act as the control plane’s “brain,” continuously observing cluster objects and reconciling the current state with your declared desired state. In this lesson, we’ll deep dive into two controllers that manage Pod replicas: ReplicationController and ReplicaSet.

Why Use Replication Controllers?

Running a single Pod is risky—if it crashes, your application goes offline. A ReplicationController (RC) maintains a specified number of identical Pods, ensuring high availability and load distribution.
  • High availability: If one Pod fails, others continue serving traffic.
The image illustrates a high availability setup with a user accessing a node containing a replication controller managing two pods.
  • Redundancy and load balancing across nodes:
The image illustrates a high availability setup with two nodes, each containing a replication controller and pods, indicating redundancy and load balancing.
  • Scaling across nodes to meet growing demand:
The image illustrates a load balancing and scaling concept using Kubernetes, showing multiple pods distributed across nodes with a replication controller managing them.

ReplicationController vs. ReplicaSet

While both controllers maintain a set of Pod replicas, ReplicaSet (RS) is the modern API (apps/v1) and supports set-based label selectors. ReplicationController (v1) is older and has fewer selector capabilities. We recommend using ReplicaSets for new deployments.

Creating a ReplicationController

  1. Define rc-definition.yaml:
  2. Apply the manifest and verify:
    Example output:
  3. List Pods managed by the RC:

Introducing ReplicaSets

A ReplicaSet manifest closely mirrors an RC, with two key differences:
  • apiVersion: apps/v1
  • selector: Required to match Pods
Apply and verify:

Labels and Selectors

Labels are key/value pairs attached to objects. A ReplicaSet’s spec.selector.matchLabels determines which Pods it manages—even pre-existing ones. Example Pod with labels:
Matching selector in a ReplicaSet:

Scaling a ReplicaSet

You can adjust replica counts by editing the YAML or using kubectl scale: Option 1: Update replicas in replicaset-definition.yaml and apply:
Option 2: Scale on the fly:
Using kubectl scale updates in-memory replica counts but does not modify your source YAML file.
For automatic scaling based on metrics, see the Horizontal Pod Autoscaler.

Command Cheat Sheet

Watch Video