How to Create ReplicaSet on Kubernetes
- Last Updated On: February 28, 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
Conclusion
I believe this blog gives you a decent understanding of ReplicaSet and how to deploy it.
Aswin Vijayan
Other Interesting Blogs
CKA Exam 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
[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 Coupon for April 2024
Hi Techies, I wanted to let you know about a pretty sweet deal with the Linux Foundation Coupon that is running now.