Bird
0
0

You want to add two labels tier=frontend and version=v2 to all pods with label app=web. Which command correctly does this?

hard📝 Workflow Q15 of 15
Kubernetes - Labels and Selectors
You want to add two labels tier=frontend and version=v2 to all pods with label app=web. Which command correctly does this?
Akubectl label pods -selector app=web tier=frontend version=v2
Bkubectl label pods --selector app=web tier=frontend version=v2
Ckubectl label pods -l app=web tier=frontend --overwrite version=v2
Dkubectl label pods --all tier=frontend version=v2
Step-by-Step Solution
Solution:
  1. Step 1: Use label selector to target pods

    The --selector or -l flag filters pods by label app=web.
  2. Step 2: Add multiple labels in one command

    You can add multiple labels by listing them separated by spaces after the resource selector.
  3. Step 3: Choose the correct syntax

    kubectl label pods --selector app=web tier=frontend version=v2 uses --selector and adds both labels correctly. kubectl label pods -selector app=web tier=frontend version=v2 is invalid because it uses a single dash for selector, kubectl label pods -l app=web tier=frontend --overwrite version=v2 misuses --overwrite, kubectl label pods --all tier=frontend version=v2 applies to all pods, not filtered.
  4. Final Answer:

    kubectl label pods --selector app=web tier=frontend version=v2 -> Option B
  5. Quick Check:

    Use --selector and list labels to add multiple [OK]
Quick Trick: Use --selector (-l) to target resources by label [OK]
Common Mistakes:
  • Using -l without double dash or wrong syntax
  • Adding --overwrite unnecessarily
  • Using --all instead of selector

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes