Problem statement
Every setting this service has is baked into its image: the log level, the retry count, the properties file it reads at boot. Changing one URL means a rebuild, a repush and a redeploy of everything. The namespace appconf is empty and waiting; the two files the service reads are in config/.
About this exercise
A ConfigMap is a namespaced API object whose entire job is to hold configuration as data, separately from the image that consumes it. Its data field is a plain map of string keys to string values, and Kubernetes never interprets what is in there - it stores and serves it.
Values arrive in a ConfigMap two ways, and the difference is only in where the bytes came from:
- From a literal - you give a key and its value directly. This suits single settings: a level, a count, a switch.
- From a file - the key becomes the file's name and the value becomes the file's entire content, newlines and all. This is how a whole properties file or JSON document lives in the cluster instead of in the image. A multi-line value is a perfectly ordinary ConfigMap value.
A ConfigMap is an object like any other, so the whole verb set applies: you can read one back in any output format, change a single key in place while every other key stays exactly as it was, and delete it. Reading one back is how you confirm what the cluster actually stored, rather than what you meant to send.
kubectl create configmap --help and kubectl explain configmap are the reference for the object and its fields.
How this project is graded
The grader reads every ConfigMap out of the live cluster and compares it against the values and file contents defined below - keys, values, and file-sourced values byte for byte. It also reads the answer files you save, because a value you record before changing something is the only evidence that the change was a change. Nothing you create is modified or removed by the grader.
What you will build
Three ConfigMaps in namespace appconf, and three files in answers/:
ConfigMap service-settings from literals
log.level info (later: debug)
max.retries 5
feature.beta off
ConfigMap service-files from the files in config/
app.properties the full contents of config/app.properties
routes.json the full contents of config/routes.json
ConfigMap probe-settings from a literal
probe.mode on
answers/settings-readback.txt service-settings read back from the cluster,
while log.level is still info
answers/probe-readback.txt probe-settings read back from the cluster,
while it still exists
answers/maps.txt the ConfigMaps of appconf, listed after the deletion
Step 1 - configuration out of the image
Create service-settings with its three literal settings, and service-files carrying both source files. The file-sourced values must be the files' contents exactly as delivered - every line, nothing trimmed, nothing reformatted.
literal_map_holds_every_defined_setting and file_sourced_keys_match_the_source_files should pass
Step 2 - read it back, then change one key
Save service-settings as the cluster reports it into answers/settings-readback.txt while log.level is still info. Then change log.level to debug. max.retries and feature.beta must come out of that edit untouched, and the object must still be the same object.
readback_captured_before_the_update and update_changes_one_key_and_leaves_the_siblings should pass
Step 3 - create, confirm, remove
Create probe-settings, save it as the cluster reports it into answers/probe-readback.txt, then delete it. Afterwards list the ConfigMaps of appconf into answers/maps.txt - the two you keep are in that listing and the deleted one is not.
probe_map_existed_before_it_was_deleted and deleted_map_is_gone_from_the_listing should pass
When every test passes
You have:
- Settings and whole configuration files living in the cluster instead of in an image
- Proof that what the cluster stored is what you sent, read back from the API
- A single key changed in place without disturbing the rest of the object
- A ConfigMap created, confirmed and removed
You do not have yet:
- Any of it reaching a container. A ConfigMap on its own changes nothing about a running process - injecting it as environment is the next exercise.
Verify
Click Test after every step.
