Problem statement
The orders service predates every logging convention the platform has: it writes everything it has to say into a file inside its own container. Namespace bundle-shipping runs it as orders-legacy, and asking the cluster what it printed returns nothing at all - the lines exist, they are simply somewhere nobody can reach. Rewriting the app is not on the table, so give it a companion that can reach them.
About this exercise
A pod can hold more than one container, and the extra ones are usually there to do something for the main one. A sidecar is exactly that: a container that runs beside the app for the whole life of the pod, adding a capability the app does not have and was never changed to provide.
Two properties of a pod make it work:
- Containers in a pod can share volumes. An emptyDir volume is created when the pod is scheduled and lives as long as the pod. Every container that mounts it sees the same directory - one writes, the other reads. Without a shared volume, a file written inside one container is invisible to every other container, which is precisely the situation orders-legacy is in.
- Every container has its own log stream. What the cluster serves as a container's log is that container's standard output, kept per container. A pod with several containers therefore has several streams, and a log read has to say which one it wants; asked without a container, it answers for the first one.
Put those together and the shape of the fix appears: the app keeps writing its file into a shared volume, and a second container reads that file and prints it on its standard output - where the cluster can serve it like any other log.
kubectl explain pod.spec.volumes, kubectl explain pod.spec.containers.volumeMounts and kubectl logs --help are the reference.
How this project is graded
The grader reads your live pod: what it declares, what each container reports, what the sidecar can see on disk, and what each container's log stream actually contains. orders-legacy is read, never repaired - your saved answer is compared against what the cluster reports for it. Re-apply your manifest after every edit; the cluster is graded, not the file.
What you will build
A pod in manifest.yaml, applied to the cluster, and one answer in answers/:
pod orders-api, namespace bundle-shippingone emptyDir volume, mounted by both containers at /var/log/app container api busybox:1.36 prints ORDERS-API STARTED on its own standard output, once, then appends one line ORDER <n> accepted to /var/log/app/orders.log every second, n counting up from 1 (this is the legacy app - the starter manifest already has it) container shipper busybox:1.36 its standard output carries the lines of /var/log/app/orders.log, from the first line onward, as they are appended
answers/silent.txt the number of log lines the cluster serves for orders-legacy (that number alone)
Step 1 - the app that nobody can hear
Ask the cluster for the legacy pod's log and record how much of it there is.
legacy_stdout_recorded_as_silent should pass
Step 2 - two containers, one volume
Bring up orders-api with both containers running, and a volume both of them mount, so the file the app writes is a file the sidecar can open.
both_containers_running_in_one_pod, shared_volume_mounted_by_both_containers and app_log_file_readable_from_the_sidecar should pass
Step 3 - out to the cluster
The sidecar's job is to put those lines on its own standard output, so the cluster serves them as its log - while the app's own stream keeps saying only what the app itself printed.
sidecar_stdout_carries_the_app_file_lines and per_container_log_selection_isolates_each_stream should pass
When every test passes
You have:
- A file inside one container turned into a log stream the cluster can serve
- Two containers cooperating through a volume neither of them owns alone
- A legacy app given a new capability without a line of it being changed
- Per-container log reads that return one container's output and not its neighbour's
You do not have yet:
- Containers that talk to each other over the network. A shared volume is only one of the things a pod shares; the next exercise uses the other.
Verify
Click Test after every step.
