Bird
0
0

Given this pod YAML snippet, what will be the output of kubectl get pods -l app.kubernetes.io/instance=webapp if the pod has these labels?

medium📝 Command Output Q4 of 15
Kubernetes - Labels and Selectors
Given this pod YAML snippet, what will be the output of kubectl get pods -l app.kubernetes.io/instance=webapp if the pod has these labels?
metadata:
  labels:
    app.kubernetes.io/name: myapp
    app.kubernetes.io/instance: webapp
    app.kubernetes.io/version: v1
ANo pods will be listed because the name label does not match
BAn error will occur due to invalid label selector syntax
CThe pod will be listed because it matches the instance label
DAll pods with any app.kubernetes.io label will be listed
Step-by-Step Solution
Solution:
  1. Step 1: Understand label selector behavior

    The command filters pods by label key and value. It lists pods where app.kubernetes.io/instance equals webapp.
  2. Step 2: Check pod labels against selector

    The pod has app.kubernetes.io/instance: webapp, so it matches and will be listed.
  3. Final Answer:

    The pod will be listed because it matches the instance label -> Option C
  4. Quick Check:

    Label selector matches pod = Pod listed [OK]
Quick Trick: Label selector matches exact key-value pairs [OK]
Common Mistakes:
  • Assuming all labels must match
  • Confusing label keys
  • Expecting errors from valid selectors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes