Bird
0
0

Which of the following is the correct minimal YAML snippet to define a Deployment selector matching pods with label app: myapp?

easy📝 Configuration Q12 of 15
Kubernetes - ReplicaSets and Deployments
Which of the following is the correct minimal YAML snippet to define a Deployment selector matching pods with label app: myapp?
Aselector: matchLabels: app: myapp
Bselector: labels: app: myapp
Cselector: matchLabels: name: myapp
Dselector: matchExpressions: - key: app operator: In values: [myapp]
Step-by-Step Solution
Solution:
  1. Step 1: Recall Deployment selector syntax

    The selector must use matchLabels with key-value pairs matching pod labels.
  2. Step 2: Check options

    selector: matchLabels: app: myapp uses correct matchLabels with app: myapp. selector: labels: app: myapp uses wrong key labels. selector: matchLabels: name: myapp uses wrong label key name. selector: matchExpressions: - key: app operator: In values: [myapp] uses matchExpressions which is valid but more complex and not minimal.
  3. Final Answer:

    selector: matchLabels: app: myapp -> Option A
  4. Quick Check:

    Use matchLabels with correct key = A [OK]
Quick Trick: Use matchLabels with exact pod label keys [OK]
Common Mistakes:
  • Using 'labels' instead of 'matchLabels'
  • Mismatching label keys in selector
  • Confusing matchLabels with matchExpressions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes