Kubernetes ReplicaSets
Step-01: Introduction to ReplicaSets¶
- What are ReplicaSets?
- What is the advantage of using ReplicaSets?
Step-02: Create ReplicaSet¶
Step-02-01: Create ReplicaSet¶
- Create ReplicaSet
- replicaset-demo.yml
Step-02-02: List ReplicaSets¶
- Get list of ReplicaSets
Step-02-03: Describe ReplicaSet¶
- Describe the newly created ReplicaSet
Step-02-04: List of Pods¶
- Get list of Pods
Step-02-05: Verify the Owner of the Pod¶
- Verify the owner reference of the pod.
- Verify under "name" tag under "ownerReferences". We will find the replicaset name to which this pod belongs to.
Step-03: Expose ReplicaSet as a Service¶
- Expose ReplicaSet with a service (Load Balancer Service) to access the application externally (from internet)
# Expose ReplicaSet as a Service kubectl expose rs <ReplicaSet-Name> --type=LoadBalancer --port=80 --target-port=8080 --name=<Service-Name-To-Be-Created> kubectl expose rs my-helloworld-rs --type=LoadBalancer --port=80 --target-port=8080 --name=my-helloworld-rs-service # List Services kubectl get service kubectl get svc - Access the Application using External or Public IP
Step-04: Test Replicaset Reliability or High Availability¶
- Test how the high availability or reliability concept is achieved automatically in Kubernetes
- Whenever a POD is accidentally terminated due to some application issue, ReplicaSet should auto-create that Pod to maintain desired number of Replicas configured to achive High Availability.
Step-05: Test ReplicaSet Scalability feature¶
- Test how scalability is going to seamless & quick
- Update the replicas field in replicaset-demo.yml from 3 to 6.
- Update the ReplicaSet
Step-06: Delete ReplicaSet & Service¶
Step-06-01: Delete ReplicaSet¶
# Delete ReplicaSet
kubectl delete rs <ReplicaSet-Name>
# Sample Commands
kubectl delete rs/my-helloworld-rs
[or]
kubectl delete rs my-helloworld-rs
# Verify if ReplicaSet got deleted
kubectl get rs
Step-06-02: Delete Service created for ReplicaSet¶
# Delete Service
kubectl delete svc <service-name>
# Sample Commands
kubectl delete svc my-helloworld-rs-service
[or]
kubectl delete svc/my-helloworld-rs-service
# Verify if Service got deleted
kubectl get svc
🎉 New Course
Ultimate DevOps Real-World Project Implementation on AWS
$15.99
$84.99
81% OFF
DEVOPS2026FEB
Enroll Now on Udemy
🎉 Offer