A ReplicaSet is a Kubernetes object that ensures a specified number of pod replicas are running at any given time. It helps keep the application available by replacing pods that fail or are deleted.
Click to reveal answer
beginner
How does a ReplicaSet know which pods to manage?
A ReplicaSet uses a label selector to identify the pods it manages. It matches pods with specific labels and ensures the desired number of those pods are running.
Click to reveal answer
beginner
What happens if a pod managed by a ReplicaSet crashes or is deleted?
The ReplicaSet detects the missing pod and creates a new pod to maintain the desired number of replicas, ensuring the application stays available.
Click to reveal answer
beginner
Which field in a ReplicaSet YAML defines the number of pod replicas?
The 'replicas' field in the ReplicaSet YAML specifies how many pod copies should be running.
Click to reveal answer
intermediate
Can a ReplicaSet manage pods created by a Deployment?
Yes, Deployments use ReplicaSets internally to manage pod replicas. Users usually interact with Deployments, which handle ReplicaSets automatically.
Click to reveal answer
What is the main purpose of a ReplicaSet in Kubernetes?
ATo ensure a specified number of pod replicas are running
BTo store container images
CTo manage network policies
DTo schedule pods on nodes
✗ Incorrect
A ReplicaSet's main job is to keep the desired number of pod replicas running.
How does a ReplicaSet select which pods to manage?
ABy pod IP addresses
BBy pod creation time
CBy matching pod labels with its selector
DBy pod resource usage
✗ Incorrect
ReplicaSets use label selectors to identify pods they manage.
If a pod managed by a ReplicaSet is deleted, what happens next?
AThe ReplicaSet scales down
BNothing happens
CThe ReplicaSet deletes all pods
DReplicaSet creates a new pod to replace it
✗ Incorrect
ReplicaSet ensures the desired number of pods by creating replacements if pods are deleted.
Which YAML field defines how many pods a ReplicaSet should maintain?
Atemplate
Breplicas
Cselector
Dmetadata
✗ Incorrect
The 'replicas' field sets the number of pod copies to run.
What Kubernetes object typically manages ReplicaSets for you?
ADeployment
BService
CConfigMap
DIngress
✗ Incorrect
Deployments create and manage ReplicaSets automatically.
Explain what a ReplicaSet is and why it is important in Kubernetes.
Think about how Kubernetes keeps your app running smoothly.
You got /4 concepts.
Describe how a ReplicaSet reacts when one of its pods fails or is deleted.
Consider what happens behind the scenes to keep your app stable.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of a ReplicaSet in Kubernetes?
easy
A. To manage network policies between pods
B. To store persistent data for pods
C. To ensure a specified number of pod replicas are running at all times
D. To schedule pods on specific nodes
Solution
Step 1: Understand ReplicaSet role
A ReplicaSet's job is to keep a stable set of pod replicas running.
Step 2: Compare options with ReplicaSet function
Only To ensure a specified number of pod replicas are running at all times describes maintaining pod replicas, which is the ReplicaSet's purpose.
Final Answer:
To ensure a specified number of pod replicas are running at all times -> Option C
Quick Check:
ReplicaSet manages pod count = A [OK]
Hint: ReplicaSet = keeps pods running in set number [OK]
Common Mistakes:
Confusing ReplicaSet with PersistentVolume
Thinking ReplicaSet manages network policies
Mixing ReplicaSet with pod scheduling
2. Which of the following is the correct minimal YAML snippet to define a ReplicaSet with 3 replicas?
ReplicaSet requires apiVersion: apps/v1 and kind: ReplicaSet. The option with apiVersion: v1 is invalid.
Step 2: Validate replicas and selector-template match
Replicas must be an integer like 3, not string 'three'. Selector labels must match template labels exactly (one option has template app: otherapp mismatch). Only one option has all correct: apps/v1, replicas: 3, matching labels with proper structure.
Final Answer:
Correct YAML with apiVersion apps/v1, replicas: 3, matching selector and template labels -> Option A
Quick Check:
YAML syntax + matching labels = D [OK]
Hint: Match selector labels exactly with template labels [OK]
Common Mistakes:
Using wrong apiVersion
Setting replicas as string instead of number
Mismatching selector and template labels
3. Given this ReplicaSet YAML snippet, what will be the number of pods running after applying it?
The spec.replicas is set to 2, so Kubernetes will try to run 2 pods matching the selector.
Step 2: Confirm selector and template labels match
Selector matches label app: test, and template labels also have app: test, so pods will be created.
Final Answer:
2 pods -> Option D
Quick Check:
replicas = 2 pods running [OK]
Hint: replicas number = pods running if labels match [OK]
Common Mistakes:
Ignoring label selector and template label matching
Assuming pods run without matching labels
Confusing replicas with container count
4. You applied a ReplicaSet YAML but no pods are created. Which of these is the most likely cause?
medium
A. The replicas field is set to 0
B. The selector labels do not match the pod template labels
C. The container image name is misspelled
D. The ReplicaSet name is missing
Solution
Step 1: Understand pod creation depends on selector matching template labels
If selector labels don't match pod template labels, ReplicaSet won't manage any pods.
Step 2: Evaluate other options
Replicas 0 means no pods, but question says pods expected. Misspelled image causes pod crash, not zero pods. Name missing causes YAML error, not silent no pods.
Final Answer:
The selector labels do not match the pod template labels -> Option B
Quick Check:
Selector-template label mismatch = no pods [OK]
Hint: Selector and template labels must match exactly [OK]
Common Mistakes:
Assuming image typo prevents pod creation
Ignoring selector-template label mismatch
Thinking ReplicaSet name is optional
5. You want to update a ReplicaSet to increase replicas from 2 to 5 but keep the same pods running without downtime. What is the best approach?
hard
A. Scale the ReplicaSet using kubectl scale command to 5 replicas
B. Delete the ReplicaSet and create a new one with replicas: 5
C. Edit the ReplicaSet YAML to set replicas: 5 and apply it
D. Change the pod template labels to new values and apply
Solution
Step 1: Understand scaling ReplicaSet
Scaling with kubectl scale updates replicas live without downtime.
Step 2: Evaluate other options
Editing YAML and applying works but less safe than scale command. Deleting ReplicaSet causes downtime. Changing labels breaks pod matching.
Final Answer:
Scale the ReplicaSet using kubectl scale command to 5 replicas -> Option A
Quick Check:
Use kubectl scale for live replica changes [OK]
Hint: Use kubectl scale to change replicas live [OK]
Common Mistakes:
Deleting ReplicaSet causes downtime
Changing labels breaks pod matching
Editing YAML directly risks errors
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.