Courseiva

CKAD Practice Question: Application Environment, Configuration and Security

Which TWO of the following are valid ways to consume a Secret named 'db-secret' in a Pod? (Choose two.)

⚠ Common exam trap

CNCF often tests the distinction between `configMapKeyRef` and `secretKeyRef` — candidates mistakenly use `configMapKeyRef` for Secrets because both are key-value stores, but Secrets require `secretKeyRef` for individual key injection.

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

✓

As environment variables using envFrom with secretRef

`envFrom` with `secretRef` allows a Pod to consume all key-value pairs from a Secret named 'db-secret' as environment variables. This is a standard Kubernetes feature for injecting Secret data into containers 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.

  • ✗

    As environment variables using env with valueFrom.configMapKeyRef

    Why it's wrong here

    Setting an individual environment variable with env.valueFrom.configMapKeyRef points to a ConfigMap key, not a Secret. Kubernetes uses secretKeyRef for pulling a specific key from a Secret into an env var, so this approach fails to access secret data and is not a valid consumption method.

  • ✓

    As environment variables using envFrom with secretRef

    Why this is correct

    A container can consume a Secret in its entirety by using envFrom with a secretRef in the container's environment specification. Kubernetes enumerates every key in the referenced Secret and creates an environment variable for each, provided the key is a valid environment variable name. This is one of the two officially supported ways to inject Secret data into a running container.

  • ✗

    As a command-line argument using $(DB_PASSWORD)

    Why it's wrong here

    The $(DB_PASSWORD) syntax in container arguments is expanded from environment variables that already exist in the container, but it cannot directly reference a Secret object. To use a Secret value in a command or argument, the Secret must first be exposed either as an environment variable via secretKeyRef or as a mounted file—there is no direct path from a Secret to the command line.

  • ✓

    As files mounted via a volume with secret.secretName

    Why this is correct

    Mounting a Secret as a filesystem volume is the second valid consumption method. The Pod spec defines a volume with secret.secretName, and then a volumeMount places each key of the Secret as a file in the container's filesystem. The file contents are the raw decoded values from the Secret, and changes to the Secret can propagate to the mounted files, unlike environment variables which are fixed at pod creation.

  • ✗

    As an imagePullSecrets entry

    Why it's wrong here

    imagePullSecrets is a Pod-level field used to authenticate to private container registries when pulling images. It references a Secret of type kubernetes.io/dockerconfigjson and only serves as a credential for the image pull operation—it never exposes the Secret data inside the container as environment variables or files. Therefore, it is not a valid way for an application to consume Secret data.

About these practice questions

One of 826 original CKAD 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 CKAD 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 CKAD exam.