CKA Workloads and Scheduling Practice Question
Which command creates a ConfigMap named 'app-config' from the file 'config.properties'?
⚠ Common exam trap
Candidates often confuse `--from-file` with `--from-env-file`; candidates often mistakenly choose `--from-env-file` because they think it reads any configuration file, but it only works with files formatted as environment variable definitions (KEY=VALUE per line), not arbitrary files like config.properties.
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' using the content of the file 'config.properties'. The `--from-file` flag reads the file and stores its entire content as a single key-value pair, where the key defaults to the filename (config.properties) and the value is the file's content. This is the standard syntax for creating a ConfigMap from a 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 --file=config.properties
Why it's wrong here
The `kubectl create configmap` command does not recognize a `--file` flag as a valid option for specifying input. This flag is invalid for creating ConfigMaps and would result in a "unknown flag" error from the `kubectl` client. To correctly specify a file whose contents should be included in the ConfigMap, the appropriate flag to use is `--from-file`.
- ✗
kubectl create configmap app-config --from-env-file=config.properties
Why it's wrong here
The `--from-env-file` flag is specifically designed to parse a file containing environment variable-like key-value pairs, where each line must be in the format `KEY=VALUE`. If `config.properties` contains arbitrary text or a different structure, this command will fail to correctly parse the file or will create a ConfigMap with unintended keys and values, rather than storing the entire file content under a single, dedicated key.
- ✗
kubectl create configmap app-config --from-literal=config.properties
Why it's wrong here
The `--from-literal` flag is used to directly provide a literal key-value pair on the command line, not to read the content of a file from the filesystem. When used as `--from-literal=config.properties`, `config.properties` would be treated as the *value* for a key (e.g., `config.properties` as the key and an empty string as value, or it expects `KEY=VALUE` format). It does not instruct `kubectl` to read the *contents* of a file named `config.properties` from the current directory.
- ✓
kubectl create configmap app-config --from-file=config.properties
Why this is correct
This command correctly uses the `--from-file` flag, which instructs `kubectl` to read the entire content of the specified file, `config.properties`. It then creates a ConfigMap named `app-config` where the key for this entry defaults to the filename, `config.properties`, and its corresponding value is the complete textual content of that file. This is the standard and intended method for incorporating file contents directly into a ConfigMap.
Go deeper
Related to this question
Learn chapter
Kubernetes Architecture Overview
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.
Key term
Ingress Resources
Ingress Resources are Kubernetes API objects that manage external access to services inside a cluster, typically HTTP and HTTPS traffic, by defining rules for routing requests based on hostnames and paths.
About these practice questions
Courseiva writes every CKA question from scratch — 302 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.