Skip to main content
In this lesson you’ll create a Kubernetes Pod by writing a YAML manifest and submitting it to the API server with kubectl apply. Using a manifest gives you versionable, declarative control over the Pod’s desired state (recommended for reproducible deployments) versus the ephemeral kubectl run imperative command. This page covers:
  • the minimal Pod manifest structure
  • a working example that runs the nginx image
  • how to apply the file and inspect the Pod with kubectl
  • a trimmed kubectl describe example and common fields

Pod manifest basics

Create a file called pod.yaml (for example, vim pod.yaml). A minimal Pod manifest has four top-level fields: Notes:
  • labels is a mapping inside metadata and is useful for selectors and organization (e.g., app: nginx).
  • containers is a YAML sequence. Each list item is a container object; the hyphen denotes a sequence item.
  • Container name is the container identifier inside the Pod and can differ from the image name.
  • For images from non-Docker Hub registries, specify the full path: registry.example.com/myrepo/myimage:tag.
Use consistent indentation (two spaces recommended). Avoid tabs — inconsistent indentation breaks YAML parsing.

Minimal Pod manifest example

Create pod.yaml with the contents below to run an nginx container:
Save the file and apply it to your cluster:

Example terminal session

A typical session creating the Pod and checking status looks like this:

Inspecting the Pod

To view detailed runtime information, use:
Below is a trimmed example of kubectl describe output (some fields omitted for brevity). This output helps you debug scheduling, image pulls, container state, events, and mounted volumes.

Tips and next steps

  • Use manifests to store desired state in source control and to recreate environments consistently.
  • When you need multiple replicas and rolling updates, transition from a Pod manifest to a Deployment manifest.
  • Add probes (livenessProbe, readinessProbe), resource requests/limits, and environment variables to the container spec as your application requirements grow.
Useful links and references:

Watch Video