Room 11
REPLICASETS
The Clone Factory
- A critical application needs to run exactly 3 replicas. The ReplicaSet ensures pods are always at the desired count.
- One of the replicas has a secret annotation - find it.
📜 Mission Briefing
- Apply
replicaset.yamlto create a ReplicaSet with 3 replicas. - Verify 3 pods are running:
kubectl get pods -l app=cloned-app. - Delete one pod manually - watch the ReplicaSet recreate it.
- Scale the ReplicaSet to 5:
kubectl scale rs cloned-app --replicas=5. - Each pod has an annotation
fragmentwith a letter. Collect all 5 fragments and sort by pod name. - The concatenated letters (sorted by pod name alphabetically) spell
replica3x.
Key Commands
| Command | Purpose |
|---|---|
kubectl get rs |
List ReplicaSets |
kubectl describe rs NAME |
ReplicaSet details |
kubectl scale rs NAME --replicas=N |
Scale replicas |
kubectl get pods -l app=NAME |
Pods by label selector |
kubectl get pods -o jsonpath='{.items[*].metadata.annotations}' |
Pod annotations |
How ReplicaSets Work
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: my-replicaset
spec:
replicas: 3
selector:
matchLabels:
app: my-app # Must match template labels
template:
metadata:
labels:
app: my-app # Must match selector
spec:
containers:
- name: app
image: nginx:alpine
# ReplicaSets ensure N pods are always running
# They use label selectors to identify their pods
# Create and manage ReplicaSets
kubectl apply -f replicaset.yaml
kubectl get rs
kubectl describe rs my-replicaset
# Scale up/down
kubectl scale rs my-replicaset --replicas=5
# Delete a pod - RS creates a new one
kubectl delete pod <pod-name>
# Note: Deployments are preferred over bare ReplicaSets
# because Deployments manage ReplicaSets and add rollout capabilities
Hints
Hint 1
List the pods and their annotations:
Hint 2
Sort by name and concatenate:
Hint 3
The password is replica3x.