Steps To Create Replica Sets In The Kubernetes

Steps To Create Replica Sets In The Kubernetes

In this blog, we will show you the Steps to create Replica sets in the Kubernetes environment.

REQUIREMENTS

  • 2 Node Cluster ( 1 Master VM with 2 Nodes)
  • Kubernetes Components

INFRASTRUCTURE OVERVIEW

PODS OVERVIEW

  • Currently, there are four orphan PODS which was created using the replication controller.
Steps to create Replica sets in the Kubernetes
  • All the POD’s are labeled with app=web env=test.
  • We will show you how to add the orphan pods into a Replica Set.

REPLICA SET BENEFITS

Steps to create Replica sets in the Kubernetes

CREATING A NEW REPLICA SET

  • From the master node, open the default text editor.
  • Add the below script in the YML file.

apiVersion: apps/v1beta2
kind: ReplicaSet
metadata:
    name: rs-web
spec:
    replicas: 4
    selector:
       matchLabels:
          app: web
    template:
       metadata:
          labels:
             app: web
             env: test
       spec:
          containers:
          – name: rs-pod
            image: nginx

  • Save and close the file.
  • Use the below command to create a new replica set.

kubectl apply -f rs.yml

  • A new replica set is created successfully.

VERIFYING THE REPLICA SET

  • Use the below command to view the list of replica set available in your environment.

kubectl get rs

Steps to create Replica sets in the Kubernetes
  • It added the orphan pods into the replica set. Also, it has not created any additional pods for the replica set.
Steps to create Replica sets in the Kubernetes
  • We can also describe the replica set using the below command.

Syntax: kubectl describe rs <replica set name>

Example: kubectl describe rs rs-web

Steps to create Replica sets in the Kubernetes
  • There are more expressions available for the replica set and will share that information in future blogs.
REFERENCE

https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/

Thanks for reading this blog. We hope it was useful for you to learn to about the steps to create Replica sets in the Kubernetes.

Loges

Leave a Reply

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