Courseiva
Kubernetes Fundamentals →mediumMultiple Choice

KCNA Kubernetes Fundamentals Practice Question

A DevOps engineer has created a ConfigMap named 'app-config' with some configuration data. They want to make that data available as environment variables in a pod. Which field in the pod spec should they use to achieve this?

⚠ Common exam trap

A common mix-up: candidates confuse `envFrom` with `env` or `volumeMounts`, thinking that mounting a ConfigMap as a volume or using individual `env` entries is the only way to expose its data, but `envFrom` is the specific field designed for bulk injection of ConfigMap keys as environment variables.

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.containers[].envFrom

The `envFrom` field in the container spec allows you to inject all key-value pairs from a ConfigMap (or Secret) as environment variables into the container. This is the most direct and efficient way to expose ConfigMap data as environment variables without needing to specify each key individually.

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.volumes

    Why it's wrong here

    Volumes mount ConfigMap data as files in a directory, not as environment variables, so the container cannot read individual keys via env. It is tempting because volumes are the standard route for injecting ConfigMap content, and would be correct when the application expects configuration as mounted files rather than environment variables.

  • ✗

    spec.containers[].volumeMounts

    Why it's wrong here

    volumeMounts pairs with a volume to expose ConfigMap keys as files inside the container, not as environment variables. It is tempting because volumeMounts is the container-side half of ConfigMap file injection, and would be correct when the application reads configuration from a mounted path rather than from environment variables.

  • ✓

    spec.containers[].envFrom

    Why this is correct

    envFrom bulk-imports every key-value pair from the referenced ConfigMap as environment variables, satisfying the requirement without enumerating each key individually. The alternative, env with valueFrom, exposes only one key per entry, so envFrom is the correct field.

  • ✗

    spec.containers[].env

    Why it's wrong here

    env sets variables individually — sourcing a value from a ConfigMap via env still requires one explicit valueFrom.configMapKeyRef entry per key you want. envFrom takes a single configMapRef and automatically creates an environment variable for every key already in the ConfigMap, with no per-key entries to write.

About these practice questions

One of 930 original KCNA practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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 KCNA 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 KCNA exam.