Bird
0
0

You want to delete all pods with the label app=frontend. Which command correctly deletes only those pods?

hard📝 Best Practice Q15 of 15
Kubernetes - kubectl Essential Commands
You want to delete all pods with the label app=frontend. Which command correctly deletes only those pods?
Akubectl delete -l app=frontend
Bkubectl delete pods --all
Ckubectl delete pods --selector app=frontend
Dkubectl delete pods app=frontend
Step-by-Step Solution
Solution:
  1. Step 1: Understand label selector syntax

    To delete pods by label, use the --selector or -l flag with the label key=value.
  2. Step 2: Identify correct command

    kubectl delete pods --selector app=frontend uses --selector app=frontend, which is the correct full flag. kubectl delete -l app=frontend uses -l but misses the resource type pods.
  3. Step 3: Confirm other options

    kubectl delete pods --all deletes all pods, not filtered. kubectl delete pods app=frontend is invalid syntax.
  4. Final Answer:

    kubectl delete pods --selector app=frontend -> Option C
  5. Quick Check:

    Use --selector or -l to filter pods by label [OK]
Quick Trick: Use --selector or -l flag to delete by label [OK]
Common Mistakes:
  • Using --all deletes everything, not filtered
  • Incorrect syntax without --selector or -l
  • Confusing label with resource name

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes