Courseiva

CKAD Practice Question: Application Environment, Configuration and Security

Which TWO of the following are valid ways to mount a Secret into a pod as environment variables? (Select exactly 2)

⚠ Common exam trap

A common mix-up: candidates confuse `configMapKeyRef`/`configMapRef` with `secretKeyRef`/`secretRef`, or invent non-existent fields like `secretEnvRef`, because the syntax for Secrets and ConfigMaps is nearly identical except for the resource-specific keyword.

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: SECRET_KEY valueFrom: secretKeyRef: name: my-secret key: key

`secretKeyRef` is the standard Kubernetes API field for referencing a specific key from a Secret object and injecting its value as an environment variable. Option E is correct because `envFrom` with `secretRef` allows you to load all key-value pairs from a Secret as environment variables into the pod, which is a valid and common pattern.

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: SECRET_KEY valueFrom: configMapKeyRef: name: my-secret key: key

    Why it's wrong here

    This reference uses configMapKeyRef, which is designed for ConfigMaps, not Secrets. Although the syntax appears similar to secretKeyRef, the API server validates the referenced resource type and will not allow a Secret to be fetched via configMapKeyRef. As a result, this would cause a schema validation error or fail when the named ConfigMap does not exist.

  • ✗

    env: - name: SECRET_KEY valueFrom: secretEnvRef: name: my-secret key: key

    Why it's wrong here

    The field secretEnvRef is not part of the Kubernetes PodSpec API. To inject a specific key from a Secret as an environment variable, the only valid field is secretKeyRef. Because secretEnvRef is an unknown field, the API server would reject the manifest with a strict decoding error, so this is not a valid mounting technique.

  • ✗

    envFrom: - configMapRef: name: my-secret

    Why it's wrong here

    The envFrom construct with configMapRef imports environment variables from a ConfigMap, not from a Secret. To consume a Secret in this manner, you must use secretRef instead. Since configMapRef points to a ConfigMap resource, referencing my-secret would cause the lookup to fail unless a ConfigMap with that exact name exists, which is not the intent.

  • ✓

    env: - name: SECRET_KEY valueFrom: secretKeyRef: name: my-secret key: key

    Why this is correct

    This correctly uses secretKeyRef to reference a specific key from a Secret. The name field identifies the Secret resource, and key specifies which entry to extract; the value is base64-decoded before being set as the environment variable. This is the standard, explicit method for injecting a single secret value into a container.

  • ✓

    envFrom: - secretRef: name: my-secret

    Why this is correct

    This uses envFrom with secretRef, which imports all key-value pairs from the referenced Secret as environment variables. It is a convenient way to bulk-load a Secret's data, though individual env entries take precedence if any collisions occur. This is valid because secretRef is the Secret-specific counterpart to configMapRef.

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.