Design a two-service application
A small application with two responsibilities
A bookstore needs to display a list of titles and the total number in stock. Instead of storing inventory inside the frontend, put the fixed book records behind an inventory API. The frontend requests those records and calculates a summary. Each part can be deployed and replaced independently. The project is deliberately stateless: there is no database, no user account and no durable storage. The frontend returns JSON, so a browser or HTTP client can display it without a separate JavaScript application.
Trace the request
A local client reaches the frontend through a loopback port-forward in the optional lab. The frontend calls http://inventory:80/books within the namespace. The name inventory resolves to the inventory Service; its selector matches inventory Pods. The Service port is 80 and the named targetPort http resolves to port 8080 in each Pod. The API returns two records. The frontend adds 3 and 2, producing totalStock 5. No Pod IP is stored in the frontend.
Read the inventory Service
apiVersion: v1kind: Servicemetadata: name: inventory namespace: bookstore-milestone labels: app.kubernetes.io/name: inventory app.kubernetes.io/part-of: bookstore-milestonespec: type: ClusterIP selector: app.kubernetes.io/name: inventory app.kubernetes.io/part-of: bookstore-milestone ports: - name: http port: 80 targetPort: httpThis is a static excerpt of application.yaml. It needs the matching Deployment and an approved cluster to serve traffic. The labels are intentionally identical on both inventory replicas, while frontend uses a different name.
Configuration and workload design
The ConfigMap supplies INVENTORY_URL as an environment variable. The frontend consumes it when its container starts; changing the ConfigMap alone does not update that environment. The full manifest defines one frontend and two inventory replicas. Each container requests 100m CPU and 64Mi memory, for 300m and 192Mi combined before scheduling overhead; limits total 750m and 384Mi. These are illustrative limits, not performance recommendations. The lab disables automatic service account token mounting and uses a non-root identity; those settings do not substitute for broader cluster security.
Read the application result
{ "titles": [ "Cloud Notes", "Linux Basics" ], "totalStock": 5}Expected response from the original application. The local smoke test checks this object, independent of JSON field order. The local test does not use cluster DNS or Service routing.
Try it yourself
Open lab-fixtures/bookstore-milestone/README.md and inspect application.yaml. Identify the two Deployment selectors, both Service ports, and the ConfigMap key. Draw the two-hop request path, then calculate the CPU and memory requests if the frontend is scaled to two replicas (400m, 256Mi). Explain why this calculation does not prove a node can schedule the Pods. Do not apply the placeholder manifests.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Design a two-service application — knowledge check
Apply the beginner milestone concepts using original offline fixtures.
What does the frontend call to retrieve books?
Which field maps Service traffic to a named container port?
What is the total CPU request for three 100m containers?
What happens to an existing container environment after a ConfigMap change?
Why separate inventory from frontend?