Courseiva

CKAD Practice Question: Application Environment, Configuration and Security

You need to create a ConfigMap named 'app-config' from a file 'config.properties'. Which kubectl command should you use?

⚠ Common exam trap

Candidates often confuse `--from-file` (which imports the entire file as a single key) with `--from-env-file` (which parses key-value pairs from a file), leading them to choose option D when they intend to import a properties file as a whole, or option B when they think `--from-literal` can accept a file path.

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` reads the file `config.properties` and creates a ConfigMap named `app-config` with a data key equal to the filename (`config.properties`) and the value set to the file's contents. This is the standard way to create a ConfigMap from a single file in Kubernetes.

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 config.properties

    Why it's wrong here

    Without the --from-file flag, kubectl interprets config.properties as the name of an additional ConfigMap, not as a source file. The command would attempt to create a second ConfigMap named 'config.properties' rather than reading its contents, and the straightforward syntax for file-based creation requires explicitly declaring the file source with --from-file.

  • ✗

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

    Why it's wrong here

    --from-literal is designed to inject literal key=value pairs directly into the ConfigMap's data, so passing config.properties without an equals sign is invalid syntax; kubectl expects a key=value format. Even if formatted properly, it would store the literal string as a value, not read the file's contents, which is why this approach cannot be used for file-based configuration data.

  • ✓

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

    Why this is correct

    The --from-file flag tells kubectl to read the specified file and create a ConfigMap with the file's base name (config.properties) as the key and its entire content as the value. This is the idiomatic Kubernetes way to populate a ConfigMap from a standalone configuration file, preserving all data exactly as-is without requiring a key=value format.

  • ✗

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

    Why it's wrong here

    The --from-env-file flag parses the file as an environment-style file where each line must be in KEY=VALUE format, and it only imports those key/value pairs; arbitrary configuration files like properties or YAML are not processed correctly. Additionally, --from-env-file can only be specified once per command, whereas --from-file can be repeated, and using it here would either fail or import nothing meaningful if the file lacks the expected format.

About these practice questions

Courseiva writes every CKAD question from scratch — 826 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or 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 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.