Kubernetes object structure
What a Kubernetes object describes
A Kubernetes object is structured data representing something the API can manage or report. A Pod is a unit in which Kubernetes runs one or more containers; the next chapter explains its lifecycle. The following manifest describes a small fictional Pod. Read it offline: it is structurally illustrative and has an intentionally non-resolvable image reference. It is not a runnable workload.
apiVersion: v1kind: Podmetadata: name: catalog-demo namespace: book-lab labels: app: catalog annotations: example.com/revision: "2"spec: restartPolicy: Never automountServiceAccountToken: false containers: - name: catalog image: example.invalid/catalog:1 resources: requests: cpu: 50m memory: 32Mi limits: cpu: 100m memory: 64MiIdentify its type
apiVersion: v1 selects the core API version for a Pod, not the Kubernetes cluster release number. kind: Pod identifies the object type. Other groups can use a value such as apps/v1, for example for a Deployment. Type and version together determine which API rules apply; changing a version string arbitrarily is not a migration.
Identify the object
metadata.name names this Pod catalog-demo. metadata.namespace places it in the fictional book-lab namespace, a named grouping for namespaced objects. Names must follow the rules for that resource. Not all resource kinds are namespaced. An alternative creation pattern for supported requests is generateName, which provides a prefix for a server-generated name. Do not set both just to make a name more unique.
Labels are small string key/value attributes used by selection mechanisms. Here app: catalog can identify Pods belonging to the catalog application. Annotations attach extra string information, such as the fictional revision. They are not labels. Neither kind of metadata supplies access control by itself.
Desired configuration lives in spec
For this Pod, spec.containers lists one container with the name catalog and an illustrative image. An image describes the packaged filesystem and configuration used to create containers. restartPolicy: Never means the ordinary container is not restarted by the Pod-level policy. automountServiceAccountToken: false avoids an unnecessary automatically mounted API credential in this illustration. The resource settings express requested and maximum CPU and memory allocations; their meaning is taught later. They are bounded example values, not sizing recommendations. Not every API object has a spec field.
Observed state lives in status
A returned object may contain additional metadata and observed state. Here is a deliberately shortened synthetic response fragment; it is not a second input manifest.
metadata: name: catalog-demo namespace: book-lab uid: "00000000-0000-4000-8000-000000000001" resourceVersion: "731"status: phase: PendingThe UID distinguishes this object instance from a later object that reuses its name. resourceVersion is an opaque API version token for operations such as change tracking; do not treat it as a timestamp or increment it manually. Pending here is an invented observation, not an actual result. The ordinary desired-state file should not copy server-managed fields or status from a retrieved object. Changing status.phase in a file is not a way to make an application ready.
Read the manifest without deploying it
Find the container list, the resource name, the namespace and the revision annotation. The matching JSON fixture holds the same input data. The separate observed JSON fixture includes a synthetic UID, resource version and status to help distinguish inputs from observations. The next lesson asks whether this structure would pass API validation; parsing is only the first step. Related reference: Kubernetes object structure.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Kubernetes object structure — knowledge check
Apply the lesson concepts to original offline scenarios.
What does `apiVersion: v1` select for a Pod?
Which field names this example Pod?
Where is the requested container image declared?
Which token distinguishes a deleted Pod from a new Pod with the same name?
Why is editing the observed phase not a way to make a Pod ready?