Courseiva

CKAD Practice Question: Application Environment, Configuration and Security

Which kubectl command creates a ConfigMap named 'app-config' from a file 'app.properties'?

⚠ Common exam trap

It's easy for candidates to confuse `--from-file` (which stores the entire file content as a single value) with `--from-env-file` (which parses the file as key-value pairs for environment variables), leading candidates to pick option C when they need to import a properties file as a single blob.

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=app.properties

`kubectl create configmap app-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 (without extension) 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 app-config --from-file=app.properties

    Why this is correct

    The --from-file flag tells kubectl to read the contents of the specified file and create a single data key in the ConfigMap, using the filename (app.properties) as the key and the file's content as the value. This is the correct imperative way to generate a ConfigMap from a file without manually writing a YAML manifest. Because the content becomes the value, any valid file format (properties, JSON, YAML, or plain text) can be stored as an opaque data entry.

  • ✗

    kubectl create configmap app-config --from-literal=app.properties

    Why it's wrong here

    The --from-literal flag expects a key=value pair as its argument, not a file path. Passing app.properties without an equals sign causes kubectl to reject the syntax or create an entry with a malformed literal, since there is no '=' delimiter to separate the key from the value. Even if it were key=value, the literal would be stored as raw text, not file content; this flag is intended for inline key-value pairs such as --from-literal=APP_COLOR=blue.

  • ✗

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

    Why it's wrong here

    The --from-env-file flag parses the specified file as a list of environment variable assignments (KEY=VALUE lines) and imports each as a separate data entry in the ConfigMap. It does not create a single entry under the filename key; instead it treats the file as a source of multiple key-value pairs, and lines without an equals sign (or with invalid syntax) are typically ignored or cause errors. This is useful when importing env vars, but not when you want the entire file stored as one data item.

  • ✗

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

    Why it's wrong here

    kubectl create configmap does not support a --file flag. The available flags are --from-file, --from-literal, and --from-env-file (along with standard global flags). Using --file would fail with an "unknown flag" error, so this command cannot create the ConfigMap as intended. The --from-file flag is the correct file-based option; --file is a common misconception because other tools like kubectl apply use -f for filenames.

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 →

How Courseiva writes practice questions · Editorial policy

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.