StaffCoder
Kubernetes
15 modules · 60 challengesSign up
Module 1 · Pods & Containers

First Pod Manifest

easyPod ManifestsPod Status & Lifecycle25%1 of 4 solved

Problem statement

Nothing runs in the new cluster yet: the service exists as a docker run command in a chat message, not as anything the cluster can schedule. manifest.yaml is the first attempt at fixing that - it carries no labels, declares no port, and points at a placeholder image.

About this exercise

A Pod is the smallest thing a Kubernetes cluster schedules: one or more containers that share a network identity and are placed together on a node. You do not start it by hand - you declare what you want and hand that declaration to the cluster, which then works to make reality match.

Every Kubernetes object has the same four top-level fields: apiVersion, kind, metadata and spec. Two parts of that matter here:

  • metadata.labels are key/value tags on the object. Nothing enforces them, and everything selects on them - services, deployments and your own queries all find pods by label. A pod without labels is invisible to everything that comes later.
  • A declared containerPort documents which port the container listens on. It opens nothing by itself; it is the contract the rest of the cluster reads.

What the cluster observed lives in .status, which you never write: the phase (Pending -> Running -> Succeeded/Failed), a per-container ready flag, the node it was placed on, and the pod's IP address. A pod that is Running but not ready is a different situation from one that never got scheduled - status tells you which.

Useful while you work: kubectl apply -f, kubectl get pod -o yaml (or -o jsonpath=... for one field), kubectl describe pod, kubectl delete pod, and kubectl explain pod.spec for the field reference. The cluster is running and kubectl is already configured.

How this project is graded

The grader reads both manifest.yaml and the live cluster: the file must declare the object correctly, and that object must actually be running. Applying your manifest is part of the exercise.

What you will build

In manifest.yaml, one Pod:

name:       checkout-api
namespace:  workloads
labels:     app=checkout-api, tier=web
container:  name web, image nginx:alpine, declared port 80

Step 1 - declare it, apply it

Fill in the manifest and apply it to the cluster. The pod must reach Running with its container reporting ready.

manifest_declares_the_pod_spec and pod_reaches_running_with_container_ready should pass

Step 2 - read what the cluster decided

The object in the cluster must carry the labels, image and port you declared. Then read two things the cluster wrote into its status and save each on its own, exactly as reported:

answers/node.txt     the node your pod was placed on
answers/pod-ip.txt   the address it was given

live_object_matches_the_declared_spec and saved_node_and_ip_match_live_status should pass

Step 3 - clean up what is no longer wanted

The namespace still holds retired-cache, a pod left over from the previous setup. Remove it - and leave everything else where it is.

retired_pod_deleted_from_the_namespace and your_pod_survived_the_cleanup should pass

When every test passes

You have:

  • A workload the cluster can schedule, declared in a file instead of typed into a shell
  • Labels that make the pod addressable by everything that comes later
  • The habit of reading .status for what actually happened - phase, readiness, node, IP
  • A clean delete that removes exactly what you named

You do not have yet:

  • Any control over how the container runs. Its command, arguments and environment are still whatever the image decided - the next exercise.

Verify

Click Test after every step.

More in Pods & Containers

See the module
Command, Args & EnvironmentOverride a container's command and arguments and inject literal plus downward-API environment variables, proven from inside the container.100%1 of 1 solvedeasyRestart Policies & LifecycleGive a completing task and a crashing server the restart policies their lifecycles need, and read phases, restart counts and exit reasons from status.100%1 of 1 solvedeasyContained Workload Bring-UpBring up a server, a configured variant and a one-shot task from bare manifests, and report every workload's identity and outcome from live status.100%1 of 1 solvedeasy

We use cookies that are necessary to run Staffcoder, and optional analytics cookies to see which pages get used. Analytics stays off unless you accept. Read our Cookie Policy.