CKAD Practice Question: Application Environment, Configuration and Security
Which kubectl command correctly creates a ConfigMap from a file named 'app.properties'?
⚠ Common exam trap
Candidates often confuse `--from-env-file` (which parses key=value lines) with `--from-file` (which imports the entire file as a single key), leading them to choose option C incorrectly.
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=app.properties
`kubectl create configmap app-config --from-file=app.properties` creates a ConfigMap by reading the entire contents of the file 'app.properties' and storing it under a key that defaults to the filename (app.properties). This is the standard way to import a file's data as a single key-value pair in a ConfigMap.
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=app.properties --from-env-file=app.properties
Why it's wrong here
Combining --from-file and --from-env-file with the same file is contradictory because --from-file stores the entire file content under a single key (the filename, e.g., app.properties), while --from-env-file parses each line into separate KEY=VALUE entries. Running both flags together would attempt to create two different representations from the same source, causing redundancy or a validation error if the file contains non-KEY=VALUE lines. Choose the flag that matches the desired ConfigMap structure rather than stacking them.
- ✗
kubectl create configmap app-config --from-literal=app.properties
Why it's wrong here
The --from-literal flag is designed for passing literal key=value strings on the command line, not for reading files; it expects an argument in the form KEY=VALUE. Given 'app.properties' literally, there is no '=' delimiter, so kubectl cannot parse it into a valid ConfigMap entry and will reject the command. Even if it were accepted, it would store the string "app.properties" as a value, not the file's contents, which defeats the purpose.
- ✗
kubectl create configmap app-config --from-env-file=app.properties
Why it's wrong here
--from-env-file is intended for .env-style files where each non-comment line contains a KEY=VALUE pair, and it creates one ConfigMap data key per non-empty line. If app.properties contains comments, whitespace, or values that are not valid environment variable syntax, kubectl will fail to import it; furthermore, the resulting ConfigMap stores multiple keys rather than the entire file as a single atomic unit. For preserving a whole configuration file as one key-value entry, --from-file is the correct choice.
- ✓
kubectl create configmap app-config --from-file=app.properties
Why this is correct
The correct flag, --from-file, imports the specified file as a single ConfigMap entry, with the key defaulting to the file's basename (app.properties) and the value being the complete file content. This is the standard way to store a raw configuration file so it can later be mounted as a volume or exposed as a single environment variable. It works for any file format, including properties, YAML, JSON, or text, without requiring the content to look like KEY=VALUE pairs.
About these practice questions
This CKAD question is part of Courseiva's 826-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 →
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.