Kubernetes and Cloud Native Associate (KCNA)Kubernetes FundamentalsHard

An application developer has created a YAML manifest for a Kubernetes Deployment. They need to ensure that their application's Pods are always running on nodes with at least 4GB of RAM and have access to a GPU. Which section of the Pod specification within the Deployment YAML would be used to define these requirements?

  1. Aspec.template.spec.nodeSelector
  2. Bmetadata
  3. Cspec.containers
  4. Dspec.template.spec.resources
Show answer & explanation

Correct answer: A. spec.template.spec.nodeSelector

To ensure Pods run on specific nodes based on hardware capabilities like RAM or GPU, `nodeSelector` is used. This field allows you to specify a map of key-value pairs, which must match the labels on the target nodes.

Why the other options are wrong

  • B. Metadata contains identifiers and labels for the Pod, not resource or node placement rules.
  • C. `spec.containers` defines the containers within the Pod, including their image and command, but not node selection.
  • D. `spec.template.spec.resources` defines CPU/memory *requests and limits* for the container, not node-level hardware requirements like GPU or minimum RAM for the node itself.

Kubernetes nodeSelector

A Pod scheduling property that constrains a Pod to only run on nodes that have specific labels.

  • Allows specific hardware or environment requirements to be met.
  • Node labels are typically set by administrators or automatically by cloud providers.
  • A Pod will only be scheduled if all `nodeSelector` labels match a node's labels.

Memory trick: NodeSelector is like a 'VIP pass' for your Pod to get into the 'right node'.

More Kubernetes Fundamentals questions