Courseiva
Workloads and Scheduling →easyMultiple Choice

CKA Workloads and Scheduling Practice Question

Which of the following creates a ConfigMap named 'my-config' from a file 'app.properties'?

⚠ Common exam trap

Test-takers frequently confuse `--from-file` (which imports a file as a single key-value pair) with `--from-env-file` (which imports a file as multiple key-value pairs, one per line), leading them to choose option D when the file is not in env-file 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 my-config --from-file=app.properties

`kubectl create configmap my-config --from-file=app.properties` reads the file `app.properties` and creates a ConfigMap with a single key-value pair, where the key is the filename (app.properties) and the value is the entire file content. This is the standard way to create 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 my-config --from-literal=app.properties

    Why it's wrong here

    This command fails because the `--from-literal` flag strictly requires a key-value pair argument formatted as `key=value`. Providing only a file path or a single string like `app.properties` results in a syntax error during execution because kubectl cannot parse a key name from the input.

  • ✓

    kubectl create configmap my-config --from-file=app.properties

    Why this is correct

    This is the correct command because the `--from-file` flag instructs kubectl to read the entire contents of the specified file. It automatically creates a single key in the ConfigMap named `app.properties` with the file's complete text content as its value.

  • ✗

    kubectl create configmap my-config --from-file=app.properties --from-env-file=app.properties

    Why it's wrong here

    This command is incorrect because it redundantly and conflictingly attempts to process the same file using two different ingestion methods simultaneously. Mixing `--from-file` and `--from-env-file` on the same source file is invalid and fails to produce a clean ConfigMap with the file preserved as a single key.

  • ✗

    kubectl create configmap my-config --from-env-file=app.properties

    Why it's wrong here

    This command is incorrect because the `--from-env-file` flag parses the target file as a list of individual, line-delimited environment variables. It does not preserve the file's overall structure or create a key named `app.properties` containing the file's raw text content.

Go deeper

Related to this question

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 →

How Courseiva writes practice questions · Editorial policy

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.