CKAD Practice Question: Application Environment, Configuration and Security
An administrator needs to create a ConfigMap named 'app-config' from a file called 'config.properties'. Which kubectl command accomplishes this?
⚠ Common exam trap
It's easy for candidates to confuse `--from-file` (which stores the file content as a single value) with `--from-env-file` (which parses key-value pairs) or `--from-literal` (which expects inline key=value syntax), leading candidates to choose options that either misinterpret the file format or incorrectly specify the key.
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 where the key is the filename (config.properties) and the value is the file's content. 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 --from-literal=config.properties
Why it's wrong here
The --from-literal flag expects key=value syntax; providing just "config.properties" without an equals sign results in a key with an empty string value. This produces a ConfigMap with data like config.properties: "" rather than the file's contents, so it fails to load the configuration data as desired.
- ✓
kubectl create configmap app-config --from-file=config.properties
Why this is correct
--from-file reads the file and stores its entire content under the key equal to the file's basename (config.properties). This preserves the raw file data as a single entry in the ConfigMap, which is exactly what an application expecting a properties file would read.
- ✗
kubectl create configmap app-config --from-env-file=config.properties
Why it's wrong here
--from-env-file parses the file line-by-line expecting KEY=VALUE lines and converts each into a separate top-level data key in the ConfigMap. A Java-style properties file with dotted keys and non-standard syntax will either fail to parse or be mangled, and the original file blob is lost.
- ✗
kubectl create configmap app-config --from-file=key1=config.properties
Why it's wrong here
The syntax key1=config.properties tells kubectl to store the file content under the custom key "key1" rather than the filename. That changes the data key that the application expects (config.properties), so the app will not find its configuration unless it is specifically looking for key1.
Go deeper
Related to this question
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 →
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.