Learning Kubernetes: ReplicationController vs ReplicaSet
As I dive deeper into Kubernetes, I’ve been exploring the concepts of ReplicationControllers and ReplicaSets—two core constructs used to ensure high availability and scalability of pods in a Kubernetes cluster. In this post, I’ll share what I learned, along with sample YAML definitions and key commands. Hopefully, it helps anyone else navigating this space too! What is a ReplicationController? A ReplicationController (RC) ensures that a specified number of pod replicas are running at any given time. While it’s considered a bit old-school now (ReplicaSet and Deployments have largely replaced it), it’s still a fundamental concept worth understanding. Here’s a sample YAML to create a ReplicationController: apiVersion: v1 kind: ReplicationController metadata: name: myrc spec: replicas: 5 template: metadata: labels: app: web spec: containers: - name: c1 image: nginx Basic ReplicationController Commands List all RCs: kubectl get rc or kubectl get replicationcontroller Delete an RC: kubectl delete rc Scale the RC: kubectl scale --replicas= rc/ What is ReplicaSet? A ReplicaSet (RS) is the next-gen version of RC, introduced with better support for label selectors, including set-based ones. It ensures that a specified number of pod replicas are maintained and is mostly used under the hood by Deployments. Example 1: Equality-Based Selector: apiVersion: apps/v1 kind: ReplicaSet metadata: name: mywebapp spec: replicas: 5 selector: matchLabels: app: web template: metadata: labels: app: web spec: containers: - name: c1 image: nginx Example 2: Set-Based Selector: apiVersion: apps/v1 kind: ReplicaSet metadata: name: webdata spec: replicas: 4 selector: matchExpressions: - key: app operator: In values: - nginx - web template: metadata: labels: app: web spec: containers: - name: c1 image: nginx Basic Replica Set Commands: List all ReplicaSets kubectl get rs This shows all the ReplicaSets in your current namespace. Describe a ReplicaSet kubectl describe rs Provides detailed information including events, pod template, and selector. Delete a ReplicaSet kubectl delete rs Deletes the ReplicaSet Scale a ReplicaSet kubectl scale rs/ --replicas=3 Adjusts the number of desired pod replicas. Edit a ReplicaSet kubectl edit rs Opens the ReplicaSet manifest in your default editor so you can make changes on the fly. Apply from a YAML file kubectl apply -f webrs.yml Creates or updates a ReplicaSet from a manifest file. View pods managed by a ReplicaSet kubectl get pods -l app=web Use label selectors to filter pods created by the ReplicaSet. Key difference between ReplicationController and ReplicaSet: Feature ReplicationController (RC) ReplicaSet (RS) API Version v1 apps/v1 Label Selector Support Equality-based only Equality & set-based Usage Legacy / older systems Modern replacement for RC Used by Deployment No Yes Flexibility Less flexible More flexible Community Support Deprecated Actively supported After getting comfortable with Replication Controllers and Replica Sets, I’ve realized they’re just the beginning. Now, I’m excited to dive into Deployments—the real game-changer for managing apps in Kubernetes!

As I dive deeper into Kubernetes, I’ve been exploring the concepts of ReplicationControllers and ReplicaSets—two core constructs used to ensure high availability and scalability of pods in a Kubernetes cluster.
In this post, I’ll share what I learned, along with sample YAML definitions and key commands. Hopefully, it helps anyone else navigating this space too!
What is a ReplicationController?
A ReplicationController (RC) ensures that a specified number of pod replicas are running at any given time. While it’s considered a bit old-school now (ReplicaSet and Deployments have largely replaced it), it’s still a fundamental concept worth understanding.
Here’s a sample YAML to create a ReplicationController:
apiVersion: v1
kind: ReplicationController
metadata:
name: myrc
spec:
replicas: 5
template:
metadata:
labels:
app: web
spec:
containers:
- name: c1
image: nginx
Basic ReplicationController Commands
List all RCs:
kubectl get rc or kubectl get replicationcontroller
Delete an RC:
kubectl delete rc
Scale the RC:
kubectl scale --replicas= rc/
What is ReplicaSet?
A ReplicaSet (RS) is the next-gen version of RC, introduced with better support for label selectors, including set-based ones. It ensures that a specified number of pod replicas are maintained and is mostly used under the hood by Deployments.
Example 1: Equality-Based Selector:
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: mywebapp
spec:
replicas: 5
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: c1
image: nginx
Example 2: Set-Based Selector:
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: webdata
spec:
replicas: 4
selector:
matchExpressions:
- key: app
operator: In
values:
- nginx
- web
template:
metadata:
labels:
app: web
spec:
containers:
- name: c1
image: nginx
Basic Replica Set Commands:
List all ReplicaSets
kubectl get rs
This shows all the ReplicaSets in your current namespace.
Describe a ReplicaSet
kubectl describe rs
Provides detailed information including events, pod template, and selector.
Delete a ReplicaSet
kubectl delete rs
Deletes the ReplicaSet
Scale a ReplicaSet
kubectl scale rs/ --replicas=3
Adjusts the number of desired pod replicas.
Edit a ReplicaSet
kubectl edit rs
Opens the ReplicaSet manifest in your default editor so you can make changes on the fly.
Apply from a YAML file
kubectl apply -f webrs.yml
Creates or updates a ReplicaSet from a manifest file.
View pods managed by a ReplicaSet
kubectl get pods -l app=web
Use label selectors to filter pods created by the ReplicaSet.
Key difference between ReplicationController and ReplicaSet:
Feature | ReplicationController (RC) | ReplicaSet (RS) |
---|---|---|
API Version | v1 |
apps/v1 |
Label Selector Support | Equality-based only | Equality & set-based |
Usage | Legacy / older systems | Modern replacement for RC |
Used by Deployment | No | Yes |
Flexibility | Less flexible | More flexible |
Community Support | Deprecated | Actively supported |
After getting comfortable with Replication Controllers and Replica Sets, I’ve realized they’re just the beginning. Now, I’m excited to dive into Deployments—the real game-changer for managing apps in Kubernetes!