CKA Workloads and Scheduling Practice Question
Which command creates a ConfigMap named 'app-config' from a file 'config.properties'?
⚠ Common exam trap
Test-takers frequently confuse `--from-file` with `--from-literal` or `--from-env-file`, or mistakenly think that `--from-file` requires an explicit key assignment, leading them to choose option A or C, while also forgetting that `kubectl create secret generic` is for Secrets, not ConfigMaps, as in option D.
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` directly reads the file `config.properties` and creates a ConfigMap named `app-config` with a key equal to the filename (i.e., `config.properties`) and the value set to the file's content. The `--from-file` flag without a key specification uses the filename as the key. Option A is incorrect because the syntax `--from-file=key=config.properties` creates a ConfigMap with the key "key", not the filename. Option C is incorrect because `--from-literal` is for literal key-value pairs, not files. Option D is incorrect because `kubectl create secret generic` creates a Secret, not 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=key=config.properties
Why it's wrong here
Incorrect. The syntax `--from-file=key=config.properties` specifies a key named "key" explicitly, so the ConfigMap will have a key "key" rather than using the filename as the key. The question expects the default behavior where the filename becomes the key.
- ✓
kubectl create configmap app-config --from-file=config.properties
Why this is correct
This command correctly generates a ConfigMap named app-config by reading the contents of the specified local file. By using the --from-file flag, Kubernetes automatically uses the filename config.properties as the key and maps the entire file content as its corresponding value. This is the standard declarative approach for importing file-based configuration into a cluster.
- ✗
kubectl create configmap app-config --from-literal=config.properties
Why it's wrong here
The --from-literal flag is designed to inject raw key-value pairs directly from the command line using a key=value syntax. Passing a file path like config.properties to this flag will fail because it does not conform to the expected format and cannot read file contents. To load configuration data directly from an external file, the --from-file flag must be utilized instead.
- ✗
kubectl create secret generic app-config --from-file=config.properties
Why it's wrong here
While this command successfully creates a Kubernetes resource from a file, it generates a Secret object instead of a ConfigMap. Secrets are intended for sensitive data like passwords or tokens and automatically Base64-encode the payload. For non-sensitive configuration data, the kubectl create configmap subcommand must be used instead.
Go deeper
Related to this question
Key term
ConfigMaps
A ConfigMap is a Kubernetes object that lets you store configuration data separately from your application code, so you can change settings without rebuilding or redeploying your container images.
Key term
kubectl Command Reference
kubectl is the command-line tool used to interact with and manage Kubernetes clusters by sending commands to the Kubernetes API.
About these practice questions
Courseiva writes every CKA question from scratch — 726 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 →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This CKA 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 CKA exam.