Bird
0
0

Why will this ReplicaSet YAML fail to create pods?

medium📝 Debug Q7 of 15
Kubernetes - ReplicaSets and Deployments
Why will this ReplicaSet YAML fail to create pods?
apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: fail-rs
spec:
  replicas: 2
  selector:
    matchLabels:
      app: fail
  template:
    metadata:
      labels:
        app: frontend
        tier: frontend
    spec:
      containers:
      - name: app
        image: busybox
        command: ["sleep", "3600"]
AThe container image busybox is invalid
BSelector does not match all labels in the pod template
CThe command syntax is incorrect
DThe replicas field must be inside template
Step-by-Step Solution
Solution:
  1. Step 1: Compare selector and pod labels

    The selector matches only app: fail, but pod template has app: frontend.
  2. Step 2: Understand label matching rules

    The pod template labels must match the selector; mismatched label values cause failure.
  3. Final Answer:

    Selector does not match all labels in the pod template -> Option B
  4. Quick Check:

    Selector must match pod labels exactly [OK]
Quick Trick: Pod template must have matching labels for selector [OK]
Common Mistakes:
  • Ignoring label mismatches between selector and pod template
  • Thinking container image or command is wrong
  • Misplacing replicas field

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes