Courseiva
Kubernetes Fundamentals →mediumMultiple Choice

KCNA Kubernetes Fundamentals Practice Question

You have a ConfigMap named 'app-config' with key 'database.url'. Which environment variable reference in a Pod spec injects this value correctly?

⚠ Common exam trap

Candidates often confuse `configMapKeyRef` with `configMapRef` (which is used with `envFrom`, not `valueFrom`) or mistakenly use `secretKeyRef` for ConfigMaps, thinking the syntax is interchangeable.

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

✓

env: - name: DATABASE_URL valueFrom: configMapKeyRef: name: app-config key: database.url

It uses the `configMapKeyRef` field under `valueFrom` to reference a specific key (`database.url`) from the ConfigMap named `app-config`. This is the standard Kubernetes syntax for injecting a single key from a ConfigMap as an environment variable into a Pod.

Answer analysis

Option-by-option breakdown

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

  • ✓

    env: - name: DATABASE_URL valueFrom: configMapKeyRef: name: app-config key: database.url

    Why this is correct

    configMapKeyRef injects a single named key from a ConfigMap as an environment variable, satisfying the requirement to map key 'database.url' into DATABASE_URL. The name field targets the 'app-config' ConfigMap and key selects the exact entry, so the container receives that value at startup.

  • ✗

    env: - name: DATABASE_URL value: "$(APP_CONFIG_DATABASE_URL)"

    Why it's wrong here

    This syntax expands a variable defined earlier in the same container's env list, and APP_CONFIG_DATABASE_URL is never defined, so the reference resolves to nothing. It is tempting because it resembles Kubernetes' dependent-variable pattern, which is correct when one environment variable must derive from another already declared.

  • ✗

    env: - name: DATABASE_URL valueFrom: secretKeyRef: name: app-config key: database.url

    Why it's wrong here

    secretKeyRef retrieves values from Secrets, not ConfigMaps, so the kubelet cannot resolve app-config as a Secret and the Pod fails. It is tempting because secretKeyRef is the standard mechanism for injecting sensitive configuration into environment variables; it would be correct if database.url were stored in a Secret rather than a ConfigMap.

  • ✗

    env: - name: DATABASE_URL valueFrom: configMapRef: name: app-config key: database.url

    Why it's wrong here

    configMapRef injects every key from the ConfigMap as environment variables and accepts no key field, so this manifest is rejected as invalid. It is tempting because configMapRef is the genuine ConfigMap-injection mechanism; it would be correct when you want all keys exposed at once, not a single named key.

About these practice questions

This KCNA question is part of Courseiva's 930-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam 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 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.