Member-only story
Kubernetes: The Pod Squad (and How to Manage Them All)
ReplicaSet
A replicaSet is a Kubernetes resource that ensures a specified number of identical pod replicas are running at any given time. It is part of Kubernetes’ declarative approach to managing applications.
ReplicaSet is a process that runs multiple instances of Pods. It constantly monitors the status of pods, and if anyone fails or terminates, then it restores by creating a new instance of the pod and deleting the old one.
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: my-replicaset
spec:
replicas: 3 # Desired number of Pod replicas
selector:
matchLabels:
app: my-app # Label selector for the Pods
template: # Pod template
metadata:
labels:
app: my-app
spec:
containers:
- name: my-container
image: nginx:latest
ports:
- containerPort: 80
replicas
→ The desired number of pods.
selector
→ A label selector to identify the pods.
template
→ A pod template is used to create the pods.
𝐖𝐡𝐲 𝐔𝐬𝐞 𝐚 𝐑𝐞𝐩𝐥𝐢𝐜𝐚𝐒𝐞𝐭?
✅ Ensures high availability by maintaining a desired number of pods.
✅ Self-healing—Replaces failed or terminated pods automatically.
✅ Works with deployments to manage rolling updates.
Key features
- Desired State Management: Maintains…