• Home
  • DevOps
  • Concept of Replication Controller and Replica Sets

Concept of Replication Controller and Replica Sets

Last updated on May 28 2022
Sankalp Rai

Table of Contents

Concept of Replication Controller and Replica Sets

Kubernetes – Replication Controller

Replication Controller is one of the key features of Kubernetes, which is responsible for managing the pod lifecycle. It is responsible for making sure that the specified number of pod replicas are running at any point of time. It is employed in time when one wants to make sure that the specified number of pod or at least one pod is running. It has the capability to bring up or down the specified no of pod.
It is a best practice to use the replication controller to manage the pod life cycle rather than creating a pod again and again.
apiVersion: v1
kind: ReplicationController ————————–> 1
metadata:
name: Tomcat-ReplicationController ————————–> 2
spec:
replicas: 3 ————————> 3
template:
metadata:
name: Tomcat-ReplicationController
labels:
app: App
component: neo4j
spec:
containers:
– name: Tomcat- ———————–> 4
image: tomcat: 8.0
ports:
– containerPort: 7474 ————————> 5

Setup Details

Kind: ReplicationController → Within the above code, we have defined the kind as replication controller which tells the kubectl that the yaml file is going to be employed for creating the replication controller.
name: Tomcat-ReplicationController → This helps in identifying the name with which the replication controller will be created. If we run the kubctl, get rc < Tomcat-ReplicationController > it will show the replication controller details.
replicas: 3 → This helps the replication controller to understand that it needs to maintain three replicas of a pod at any point of time within the pod lifecycle.
name: Tomcat → Within the spec section, we have defined the name as tomcat which will tell the replication controller that the container present inside the pods is tomcat.
containerPort: 7474 → It helps in making sure that all the nodes within the cluster where the pod is running the container inside the pod will be exposed on the equivalent port 7474.

devops
devops

Here, the Kubernetes service is working as a load balancer for three tomcat replicas.

Kubernetes – Replica Sets

Replica Set ensures how many replica of pod should be running. It can be considered as a replacement of replication controller. The key difference between the replica set and the replication controller is, the replication controller only supports equality-based selector whereas the replica set supports set-based selector.
apiVersion: extensions/v1beta1 ———————>1
kind: ReplicaSet ————————–> 2
metadata:
name: Tomcat-ReplicaSet
spec:
replicas: 3
selector:
matchLables:
tier: Backend ——————> 3
matchExpression:
{ key: tier, operation: In, values: [Backend]} ————–> 4
template:
metadata:
lables:
app: Tomcat-ReplicaSet
tier: Backend
labels:
app: App
component: neo4j
spec:
containers:
– name: Tomcat
image: tomcat: 8.0
ports:
– containerPort: 7474
Setup Details
• apiVersion: extensions/v1beta1 → Within the above code, the API version is the advanced beta version of Kubernetes which supports the concept of replica set.
• kind: ReplicaSet → We have defined the kind as the replica set which helps kubectl to understand that the file is employed to create a replica set.
• tier: Backend → We have defined the label tier as backend which creates a matching selector.
• {key: tier, operation: In, values: [Backend]} → This will help matchExpression to understand the matching condition we have defined and within the operation which is employed by matchlabel to find details.
Run the above file using kubectl and create the backend replica set with the provided definition within the yaml file.

devops 1
devops

So, this brings us to the end of blog. This Tecklearn ‘Concept of Replication Controller and Replica Sets’ blog helps you with commonly asked questions if you are looking out for a job in DevOps. If you wish to learn Kubernetes and build a career in DevOps domain, then check out our interactive, Continuous Orchestration using Kubernetes Training, that comes with 24*7 support to guide you throughout your learning period. Please find the link for course details:

Continuous Orchestration using Kubernetes

Continuous Orchestration using Kubernetes Training

About the Course

Tecklearn has specially designed this Continuous Orchestration using Kubernetes Training Course to advance your skills for a successful career in this domain. Kubernetes training helps you master the container orchestration tool. As part of the training, you will learn detailed Kubernetes, architecture of Kubernetes, what are Kubernetes Pods, node, how to deploy Kubernetes, creating a Kubernetes cluster, what are the various services available and how Kubernetes makes container orchestration simple. You will get an in-depth knowledge of these concepts and will be able to work on related demos. Upon completion of this online training, you will hold a solid understanding and hands-on experience with Kubernetes.

Why Should you take Continuous Orchestration using Kubernetes Training?

• The average salary for people who possess Kubernetes as a skill is $117,000. – PayScale.com
• Apple, Capital One, AT&T, Oracle, Raytheon & many other MNC’s worldwide use Kubernetes across industries.
• The Kubernetes orchestration engine powers some of the biggest and most complex deployments in the world.

What you will Learn in this Course?

Introduction to DevOps
• What is Software Development
• Software Development Life Cycle
• Why DevOps?
• What is DevOps?
• DevOps Lifecycle
• DevOps Tools
• Benefits of DevOps
• How DevOps is related to Agile Delivery
• DevOps Implementation
Continuous Orchestration using Kubernetes
• Containers and Container Orchestration
• Introduction to Kubernetes
• Docker Swarm vs Kubernetes
• Kubernetes Architecture
• Deploying Kubernetes using Kubeadms
• Alternate ways of deploying Kubernetes
• Understanding YAML
• Creating a Deployment in Kubernetes using YAML
• Creating a Service in Kubernetes
• Installing Kubernetes Dashboard
• Deploying an App using Dashboard
• Using Rolling Updates in Kubernetes

0 responses on "Concept of Replication Controller and Replica Sets"

Leave a Message

Your email address will not be published. Required fields are marked *