Courseiva
Workloads and SchedulingmediumMultiple ChoiceObjective-mapped

CKA Workloads and Scheduling Practice Question

You have a DaemonSet that runs a logging agent. You want to ensure it only runs on nodes with GPU. Which field should you set in the DaemonSet's pod template spec?

⚠ Common exam trap

It's easy for candidates to confuse `spec.selector` (which manages pod ownership) with `nodeSelector` (which manages scheduling constraints), or they over-engineer by choosing node affinity when the simpler `nodeSelector` is sufficient for the question's requirement.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

spec.template.spec.nodeSelector

`spec.template.spec.nodeSelector` is a simple, direct field in the Pod template spec that constrains which nodes the DaemonSet's pods can be scheduled on. By setting a key-value pair like `gpu: true`, you ensure the logging agent only runs on nodes that have that label, which is the standard Kubernetes mechanism for node-level selection without complex expressions.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • spec.selector

    Why it's wrong here

    spec.selector within a DaemonSet definition is used by the DaemonSet controller to identify and manage the pods it creates. It must match the labels defined in spec.template.metadata.labels to ensure the controller correctly tracks its own pods. This field is crucial for the DaemonSet's operational integrity but plays no role in determining which nodes the DaemonSet pods are scheduled onto; it only identifies which pods belong to the DaemonSet.

  • spec.template.spec.nodeSelector

    Why this is correct

    spec.template.spec.nodeSelector is the correct and most straightforward method to constrain a DaemonSet to run only on nodes possessing specific labels. By defining a map of key-value pairs here, the DaemonSet controller will only create pods on nodes that match all of these labels. This effectively filters the cluster's nodes, ensuring the logging agent runs exclusively on the desired subset of infrastructure.

  • spec.template.spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution

    Why it's wrong here

    This field defines a hard requirement for a pod to be scheduled on nodes matching specified criteria, such as the presence of a GPU label. While `requiredDuringSchedulingIgnoredDuringExecution` correctly enforces a strict node selection policy, it is typically used for *pods* that need to be scheduled on specific nodes. For a DaemonSet, which needs to run *one pod per qualifying node*, the more direct and common approach to filter which nodes the DaemonSet controller considers is often `nodeSelector` or the broader `nodeAffinity` field itself, which encompasses `requiredDuringSchedulingIgnoredDuringExecution`. This option is tempting because it accurately describes a mechanism for enforcing node requirements.

  • spec.template.spec.nodeName

    Why it's wrong here

    spec.template.spec.nodeName directly specifies the name of a single node where a pod must be scheduled. While it forces a pod onto a particular node, applying this to a DaemonSet's spec.template would restrict the DaemonSet to run only one pod on that single named node. This fundamentally contradicts the DaemonSet's purpose of running one pod per qualifying node across the cluster, making it unsuitable for a logging agent intended for broad deployment.

About these practice questions

Courseiva writes every CKA question from scratch — 302 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This CKA practice question is part of Courseiva's free CNCF certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the CKA exam.