Difference between a replica set and replication controller

+2 votes

What's the difference between a replica set and replication controller?

Apr 17, 2019 in Kubernetes by Jinu
25,756 views

2 answers to this question.

0 votes

Replica Set and Replication Controller do almost the same thing. Both of them ensure that a specified number of pod replicas are running at any given time. The difference comes with the usage of selectors to replicate pods. Replica Set use Set-Based selectors while replication controllers use Equity-Based selectors.

answered Apr 17, 2019 by Sahit
Nice ans, would be more helpful with example.
Heyy! Have a look at my answer. Please register at Edureka Community and upvote if you think it is helpful.
+1 vote

Olaaa Jinu!

Replica set and replication controller - Both the terms have the word replica. Why do we need to replicate anything? Let's start with that. 

There are multiple ways your container can crash. Replication is used for the core purpose of Reliability, Load Balancing, and Scaling.

There are two main types of Replications in Kubernetes - Replica sets and Replication controller.

The replication controller makes sure that few pre-defined pods always exist. So in case of a pod crashes, the replication controller replaces it.

apiVersion: v1
kind: ReplicationController
metadata:
  name: example
spec:
  replicas: 3
  selector:
    app: example
  template:
    metadata:
      name: example
      labels:
        app: example
    spec:
      containers:
      - name: example
        image: example/rc
        ports:
        - containerPort: 80

Replica sets are comparatively more useful. In recent times replication sets have replaced replication controllers. What is so special about them? Let's have a look

Replica sets have a few more functionalities when compared to the replication controller. 

apiVersion: extensions/v1beta1
 kind: ReplicaSet
 metadata:
   name: example
 spec:
   replicas: 3
   selector:
     matchLabels:
       app: example
   template:
     metadata:
       labels:
         app: example
         environment: dev
     spec:
       containers:
       - name: example
         image: example/rs
         ports:
         - containerPort: 80

In this case, we are using match labels instead of labels which could easily be written like this:

...
spec:
   replicas: 3
   selector:
     matchExpressions:
      - {key: app, operator: In, values: [example, example, rs]}
      - {key: teir, operator: NotIn, values: [production]}
  template:
     metadata:
...
answered Dec 19, 2019 by Kalgi
• 52,350 points

Related Questions In Kubernetes

0 votes
1 answer

What's the difference betweena a deployment and a stateful set?

Both the deployments and replication controllers are ...READ MORE

answered Oct 3, 2018 in Kubernetes by ajs3033
• 7,300 points
4,442 views
0 votes
1 answer

What's the difference between kubernetes load balancer and ingress controller?

Load Balancer: So Kubernetes LoadBalancer just points ...READ MORE

answered Jan 4, 2019 in Kubernetes by DareDev
• 6,890 points
13,877 views
0 votes
2 answers

Difference between a Deployment and a DaemonSet in Kubernetes

Adding to @Rohit's answer, I'll explain about ...READ MORE

answered Jan 6, 2019 in Kubernetes by Ramya
4,696 views
0 votes
1 answer

Difference between kubectl apply and kubectl create?

These are two very different approaches. kubectl ...READ MORE

answered Sep 11, 2018 in Kubernetes by ajs3033
• 7,300 points
14,487 views
+1 vote
1 answer
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17, 2019 in Others by anonymous
15,417 views
+4 votes
1 answer

Installing Web UI (Dashboard):kubernetes-dashboard on main Ubuntu 16.04.6 LTS (Xenial Xerus) server

Follow these steps: $ kubeadm reset $ kubeadm init ...READ MORE

answered Apr 12, 2019 in Kubernetes by Kalgi
• 52,350 points

reshown Apr 12, 2019 by Kalgi 7,034 views
0 votes
1 answer

What is a Replication Controller

If there are too many pods, the ...READ MORE

answered Oct 26, 2018 in Kubernetes by Kalgi
• 52,350 points
728 views
0 votes
1 answer

How do you set-up Mongo replica set on Kubernetes?

Follow these steps To create a Kubernetes 1.5 ...READ MORE

answered Aug 30, 2018 in Kubernetes by Kalgi
• 52,350 points
1,981 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP