Which command creates a ConfigMap named 'app-config' from a file named 'config.properties'?
The `kubectl create configmap` command with `--from-file` reads the contents of the specified file and stores it as a single key (defaulting to the filename, `config.properties`) in the ConfigMap. This is the idiomatic way to import a configuration file's raw data without parsing or transforming it, making it perfect for arbitrary property files, YAML, or JSON. The resulting ConfigMap can then be mounted as a volume or consumed as environment variables by pods.
Why this answer
`kubectl create configmap app-config --from-file=config.properties` creates a ConfigMap named `app-config` with a single key `config.properties` (the filename) and the file's entire content as its value. The `--from-file` flag does not parse the file into separate key-value pairs. To parse lines like KEY=VALUE, you would use `--from-env-file`.
Exam trap
The trap here is confusing `--from-file` with `--from-env-file`, as candidates often assume any file with key-value pairs will be parsed automatically, but `--from-file` treats the entire file as a single value, while `--from-env-file` parses each line as a separate key-value pair.
How to eliminate wrong answers
Option B is wrong because `--from-env-file` is used to import a file in the format of environment variables (e.g., `KEY=VALUE` lines) and creates a ConfigMap with each line as a separate key-value pair, not a single key from the filename. Option C is wrong because `--from-literal` is used to specify key-value pairs directly on the command line (e.g., `key=value`), not to reference a file. Option D is wrong because `kubectl apply` is used to apply a configuration from a file or stdin, not to create a ConfigMap from a properties file; the correct command for creation is `kubectl create configmap`.