Bird
0
0

Which of the following is the correct YAML snippet to define a DaemonSet selector matching label app: node-agent?

easy📝 Configuration Q3 of 15
Kubernetes - Scheduling
Which of the following is the correct YAML snippet to define a DaemonSet selector matching label app: node-agent?
Aselector: labels: app: node-agent
Bselector: matchLabels: app: node-agent
Cselector: matchExpressions: - key: app operator: Exists
Dselector: matchLabels: app: node-agent matchExpressions: - key: role operator: Exists
Step-by-Step Solution
Solution:
  1. Step 1: Understand selector syntax

    DaemonSet selector uses matchLabels or matchExpressions under selector.
  2. Step 2: Identify correct syntax for label match

    selector: matchLabels: app: node-agent correctly uses matchLabels with app: node-agent. selector: labels: app: node-agent uses invalid key labels. selector: matchExpressions: - key: app operator: Exists uses matchExpressions with operator: Exists, matching presence of app key regardless of value. selector: matchLabels: app: node-agent matchExpressions: - key: role operator: Exists mixes both but requires role label existence.
  3. Final Answer:

    selector: matchLabels: app: node-agent -> Option B
  4. Quick Check:

    Correct selector syntax = matchLabels [OK]
Quick Trick: Use matchLabels for simple label selectors in DaemonSet [OK]
Common Mistakes:
  • Using 'labels' instead of 'matchLabels' under selector
  • Incorrect indentation or YAML formatting
  • Mixing matchLabels and matchExpressions incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes