CKAD Practice Question: Application Environment, Configuration and Security
A developer wants to create a ConfigMap named 'app-config' with two key-value pairs: 'color=blue' and 'size=large'. Which kubectl command should they use?
⚠ Common exam trap
Test-takers frequently confuse `--from-literal` with `--from-file` or try to use comma-separated syntax, not realizing that each literal must be specified with its own `--from-literal` flag in the exact `key=value` format.
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=color=blue --from-literal=size=large
`kubectl create configmap` with `--from-literal` allows specifying key-value pairs directly in the command line. Each literal must be provided as a separate `--from-literal=key=value` flag, and this command correctly creates the ConfigMap with the two entries 'color=blue' and 'size=large'.
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=color,size --value=blue,large
Why it's wrong here
The --from-literal flag does not accept a comma-separated list of keys and does not have an associated --value flag; each literal must be supplied as a single key=value pair. The invalid syntax here would cause kubectl to fail with a parse error, and no ConfigMap would be created. This command is also attempting to set two keys with one literal specification, which is unsupported.
- ✓
kubectl create configmap app-config --from-literal=color=blue --from-literal=size=large
Why this is correct
This is the correct way to create a ConfigMap from literal values: each --from-literal flag declares one key-value pair, and repeating the flag adds multiple entries to the ConfigMap's data field. The resulting resource will have data containing color: blue and size: large. This syntax is unambiguous, follows the kubectl CLI contract, and works in scripts without external files.
- ✗
kubectl create configmap app-config --from-env-file=color=blue,size=large
Why it's wrong here
The --from-env-file flag expects a path to a file that contains lines in KEY=VALUE format, not an inline comma-separated list. When you write --from-env-file=color=blue,size=large, kubectl treats the entire string after '=' as a filename, so it will try to open a file named 'color=blue,size=large' and fail because it does not exist. Even if the file existed, its contents would need to be in the env-file format for the data to be parsed correctly.
- ✗
kubectl create configmap app-config --from-file=color=blue --from-file=size=large
Why it's wrong here
The --from-file flag is designed to import the contents of a file into a ConfigMap entry, using the filename as the default key unless a key is specified with 'key=path' syntax. Here, 'color=blue' is interpreted as a relative file path (or key=filename) but no such file exists, so the command errors out. It does not treat the equals sign as an assignment of a literal value; the values are file contents, not inline strings.
About these practice questions
Courseiva writes every CKAD question from scratch — 826 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 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.