Bird
0
0

Which of the following is the correct syntax to add a recommended label app.kubernetes.io/name: myapp to a pod YAML?

easy📝 Configuration Q12 of 15
Kubernetes - Labels and Selectors
Which of the following is the correct syntax to add a recommended label app.kubernetes.io/name: myapp to a pod YAML?
Ametadata: labels: app.kubernetes.io/name: myapp
Bspec: labels: app.kubernetes.io/name: myapp
Cmetadata: annotations: app.kubernetes.io/name: myapp
Dspec: annotations: app.kubernetes.io/name: myapp
Step-by-Step Solution
Solution:
  1. Step 1: Identify where labels belong in Kubernetes YAML

    Labels are defined under metadata.labels in resource manifests.
  2. Step 2: Check the options for correct placement

    metadata: labels: app.kubernetes.io/name: myapp correctly places the label under metadata.labels. Labels belong under metadata, not spec, and should use labels not annotations.
  3. Final Answer:

    metadata: labels: app.kubernetes.io/name: myapp -> Option A
  4. Quick Check:

    Labels go under metadata.labels = B [OK]
Quick Trick: Labels always go under metadata.labels in YAML [OK]
Common Mistakes:
  • Putting labels under spec instead of metadata
  • Confusing labels with annotations
  • Incorrect indentation in YAML

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes