CKAD Practice Question: Application Environment, Configuration and Security
Which command creates a ConfigMap named 'app-config' with two keys: 'key1=value1' and 'key2=value2'?
⚠ Common exam trap
Watch out — candidates often confuse `--from-literal` with `--from-file` or `--from-env-file`, or incorrectly assume that `--from-literal` accepts comma-separated syntax, leading them to choose options that either attempt to read nonexistent files or create a single malformed 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-literal key1=value1 --from-literal key2=value2
`kubectl create configmap` with the `--from-literal` flag allows you to specify key-value pairs directly on the command line. Each `--from-literal` flag creates one entry in the ConfigMap, so using two separate flags correctly creates a ConfigMap named 'app-config' with keys 'key1' and 'key2' mapped to 'value1' and 'value2' respectively.
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 key1=value1 --from-literal key2=value2
Why this is correct
Using `kubectl create configmap app-config --from-literal key1=value1 --from-literal key2=value2` is correct because the `--from-literal` flag is designed to accept exactly one `key=value` pair, and repeating the flag accumulates each pair into the ConfigMap's `data` field. This is the canonical CLI syntax for defining inline literals directly from the command line, with no dependency on files or external input.
- ✗
kubectl create configmap app-config --from-literal=key1=value1,key2=value2
Why it's wrong here
The comma-separated form `--from-literal=key1=value1,key2=value2` fails because the flag's parser treats the entire string after the first `=` as the value, producing a single key `key1` with the value `value1,key2=value2` rather than two separate entries. There is no comma-delimited list support in `--from-literal`; using commas corrupts the key/value structure and would not create the desired two key-value pairs.
- ✗
kubectl create configmap app-config --from-file key1=value1 --from-file key2=value2
Why it's wrong here
`--from-file` is explicitly for reading data from a file, not for inline literals. When you write `--from-file key1=value1`, kubectl interprets `key1=value1` as a file path and attempts to open a file with that literal name, which will fail with a "no such file or directory" error unless a file named exactly that happens to exist. Even if it existed, the content of that file would be the value, not the literal string after `=`.
- ✗
kubectl create configmap app-config --from-env-file=key1=value1 --from-env-file=key2=value2
Why it's wrong here
`--from-env-file` expects a path to a file that contains `KEY=VALUE` lines, not inline `key=value` pairs. Using `--from-env-file=key1=value1` makes kubectl treat `key1=value1` as a file path, causing an error because no such file exists. Moreover, you typically use only one `--from-env-file` flag to import an entire environment file at once; multiple flags with inline assignments are nonsensical and outside the flag's contract.
Go deeper
Related to this question
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.