Bird
0
0

You tried to add a label to a pod using this command:

medium📝 Troubleshoot Q6 of 15
Kubernetes - Labels and Selectors
You tried to add a label to a pod using this command:
kubectl annotate pod mypod env=production
Why did this not work as expected?
ABecause labels cannot have '=' in the command.
BBecause the command adds an annotation, not a label.
CBecause the pod name is missing.
DBecause the pod must be restarted first.
Step-by-Step Solution
Solution:
  1. Step 1: Identify the command used

    The command used is 'kubectl annotate', which adds annotations, not labels.
  2. Step 2: Understand correct command for labels

    To add labels, use 'kubectl label' instead of 'annotate'.
  3. Final Answer:

    The command adds annotation, not label, so it did not add a label. -> Option B
  4. Quick Check:

    Use 'kubectl label' to add labels [OK]
Quick Trick: 'annotate' adds annotations; 'label' adds labels [OK]
Common Mistakes:
  • Using annotate instead of label
  • Assuming '=' is invalid in label commands
  • Thinking pod restart is needed

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes