nerdexam
Docker

DCA · Question #165

Two pods bear the same label, app: dev. Will a label selector matching app: dev match both of these pods?

The correct answer is D. Yes, if the pods are in the same Kubernetes namespace as the object bearing the label selector. Yes, a label selector matching app: dev will match both pods if they possess this label and are located within the same Kubernetes namespace as the object using the selector.

Submitted by tyler.j· Apr 18, 2026Container Orchestration

Question

Two pods bear the same label, app: dev. Will a label selector matching app: dev match both of these pods?

Options

  • AYes, as long as all the containers in those pods are passing their livenessProbes and
  • BYes, if both pods were pre-existing when the label selector was declared.
  • CYes, if the pods are in the same Kubernetes namespace as the object bearing the label selector
  • DYes, if the pods are in the same Kubernetes namespace as the object bearing the label selector

How the community answered

(24 responses)
  • B
    4% (1)
  • C
    4% (1)
  • D
    92% (22)

Why each option

Yes, a label selector matching `app: dev` will match both pods if they possess this label and are located within the same Kubernetes namespace as the object using the selector.

AYes, as long as all the containers in those pods are passing their livenessProbes and

Pod health (livenessProbes/readinessProbes) does not affect whether a label selector matches a pod; it only affects whether the pod is considered ready or available for traffic.

BYes, if both pods were pre-existing when the label selector was declared.

The existence of pods before a label selector is declared does not impact matching; label selectors dynamically evaluate current labels at any given time.

CYes, if the pods are in the same Kubernetes namespace as the object bearing the label selector

This statement is identical to choice D, which is the correct answer and accurately describes the conditions for label selector matching.

DYes, if the pods are in the same Kubernetes namespace as the object bearing the label selectorCorrect

Kubernetes label selectors dynamically match resources based solely on their assigned labels, irrespective of their health or creation time. Importantly, label selectors are namespace-scoped, meaning an object (like a Service or Deployment) with a selector will only find matching pods within its own Kubernetes namespace.

Concept tested: Kubernetes label selectors and namespace scope

Source: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/

Topics

#Labels#Selectors#Namespaces#Pods

Community Discussion

No community discussion yet for this question.

Full DCA Practice