
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
- We have already installed and configured the 2 Node cluster in our demo environment.
- Please check the URL https://blog.assistanz.com/steps-to-install-kubernetes-cluster-manually-using-centos-7/ for more information.
PODS OVERVIEW
- Currently, there are four orphan PODS which was created using the replication controller.
- 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
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
- It added the orphan pods into the replica set. Also, it has not created any additional pods for the replica set.
- We can also describe the replica set using the below command.
Syntax: kubectl describe rs <replica set name>
Example: kubectl describe rs rs-web
- 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