How to Create ReplicaSet on Kubernetes

In this blog, we will see about replicaset and how to create replicaset.

What is ReplicaSet?

ReplicaSet is an object on Kubernetes, which runs identical pods in our desired number. ReplicaSet is managed and controlled by the ReplicaSet controller, which maintains the desired number of replicas you specify.

The main benefits of ReplicaSet are high availability, scalability, and reliability.

Now, let’s see about how to create ReplicaSet.

How to create ReplicaSet

In this example, we are going to deploy three replicas of the Nginx webserver using ReplicaSet, to do that create YAML file replicas.yaml and copy the below content in it

apiVersion: apps/v1
kind: ReplicaSet
  name: nginx
  replicas: 3
      app: nginx
        app: nginx
      - name: nginx
        image: nginx:latest       

This YAML file will deploy a ReplicaSet and the ReplicaSet creates three replicas of the latest Nginx web server on the default namespace.

Run the following command to deploy the ReplicaSet

kubectl apply -f replicas.yaml

You can check the status of your ReplicaSet and replica pods using the following command

ReplicaSet: Replicaset status check


I believe this blog gives you a decent understanding of ReplicaSet and how to deploy it.

Other Interesting Blogs

Leave a Comment

Share via
Copy link
Powered by Social Snap