![](https://scriptcrunch.com/wp-content/uploads/2024/02/replicaset.png)
How to Create ReplicaSet on Kubernetes
- Last Updated On: February 15, 2024
- By: Aswin Vijayan
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
metadata:
name: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- 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](https://scriptcrunch.com/wp-content/uploads/2024/02/image-14.png)
Conclusion
I believe this blog gives you a decent understanding of ReplicaSet and how to deploy it.
![](https://scriptcrunch.com/wp-content/uploads/2024/02/replicaset.png)
Aswin Vijayan
Other Interesting Blogs
![CKA Exam Guide](https://scriptcrunch.com/wp-content/uploads/2020/09/cka-exam-guide--300x176.png)
CKA Certification Study Guide (Certified Kubernetes Administrator)
This comprehensive CKA certification exam study guide covers all the important aspects of the Certified Kubernetes Administrator exam and useful resources. Passing
![CKA Exam Guide](https://scriptcrunch.com/wp-content/uploads/2020/09/cka-exam-guide-.png)
![Linux Foundation LFCA & LFCS](https://scriptcrunch.com/wp-content/uploads/2022/07/lfcs-lfca-300x176.png)
[40% OFF] Linux Foundation LFCA, LFCS & LFCT Exam Voucher Codes
Linux Foundation has announced up to a $284 discount on its Linux certification programs Linux Foundation Certified IT Associate (LFCA) and Linux
![Linux Foundation LFCA & LFCS](https://scriptcrunch.com/wp-content/uploads/2022/07/lfcs-lfca.png)
![Exclusive Linux Foundation Coupon Codes](https://scriptcrunch.com/wp-content/uploads/2023/11/linux-foundation-coupon-300x176.png)
Linux Foundation Coupon for September 2024
Hi Techies, I wanted to let you know about a pretty sweet deal with the Linux Foundation Coupon that is running now.
![Exclusive Linux Foundation Coupon Codes](https://scriptcrunch.com/wp-content/uploads/2023/11/linux-foundation-coupon.png)