Courseiva

CKAD Practice Question: Application Environment, Configuration and Security

Which command creates a ConfigMap named 'app-config' from a file named 'config.properties'?

⚠ Common exam trap

It's easy for candidates to confuse `--from-file` with `--from-env-file`, as candidates often assume any file with key-value pairs will be parsed automatically, but `--from-file` treats the entire file as a single value, while `--from-env-file` parses each line as a separate key-value pair.

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

✓

kubectl create configmap app-config --from-file=config.properties

`kubectl create configmap app-config --from-file=config.properties` creates a ConfigMap named `app-config` with a single key `config.properties` (the filename) and the file's entire content as its value. The `--from-file` flag does not parse the file into separate key-value pairs. To parse lines like KEY=VALUE, you would use `--from-env-file`.

Answer analysis

Option-by-option breakdown

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

  • ✓

    kubectl create configmap app-config --from-file=config.properties

    Why this is correct

    The `kubectl create configmap` command with `--from-file` reads the contents of the specified file and stores it as a single key (defaulting to the filename, `config.properties`) in the ConfigMap. This is the idiomatic way to import a configuration file's raw data without parsing or transforming it, making it perfect for arbitrary property files, YAML, or JSON. The resulting ConfigMap can then be mounted as a volume or consumed as environment variables by pods.

  • ✗

    kubectl create configmap app-config --from-env-file=config.properties

    Why it's wrong here

    `--from-env-file` is specifically designed to parse a file containing `KEY=VALUE` lines and create each line as a separate entry in the ConfigMap. If the file is not in that strict format, the command will fail with an error, and even if it parses, it will not preserve the file as a single key. The generic file import requires `--from-file`, not `--from-env-file`, which is a common confusion because both flags appear similar but serve fundamentally different purposes.

  • ✗

    kubectl create configmap app-config --from-literal=config.properties

    Why it's wrong here

    The `--from-literal` flag expects a key=value pair, not a file path; `--from-literal=config.properties` would create a literal key named "config.properties" with an empty value, failing to read the file's contents. This option is tempting because `--from-literal` is commonly used to inject small configuration values directly, and a user might mistakenly assume it accepts a filename when the correct mechanism is `--from-file=config.properties`.

  • ✗

    kubectl apply configmap app-config --from-file=config.properties

    Why it's wrong here

    `kubectl apply` is a declarative management command used to apply configuration from a file or stdin to a resource; it does not have a `configmap` subcommand. The `apply` verb expects a resource manifest (YAML/JSON) that defines the desired state, whereas `create` is the imperative verb for generating resources from flags like `--from-file`. So `kubectl apply configmap ...` is not a valid kubectl command and will be rejected by the CLI.

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.