Skip to main content
In this lesson we’ll create a Pod by writing a YAML manifest and applying it with kubectl instead of using kubectl run. Using a manifest gives you a reproducible, versionable definition you can store in source control.
A presentation slide showing a turquoise video-camera icon on the left and a dark curved panel on the right with the title "Demo — Pod Using YAML."
What you’ll do:
  1. Author a Pod manifest in YAML.
  2. Apply it with kubectl apply -f pod.yaml.
  3. Inspect the Pod with kubectl get and kubectl describe.
Editors: you can use any plain-text editor — Notepad / Notepad++ on Windows, or vim/vi/nano on Linux. An editor with YAML syntax highlighting helps avoid indentation errors.
YAML is whitespace-sensitive. Use consistent indentation (commonly two spaces) and avoid tabs. A linting tool or editor with YAML support can catch mistakes before you apply the manifest.
Below is the manifest we’ll save as pod.yaml. It uses the four required top-level keys for a basic Pod: apiVersion, kind, metadata, and spec.
Top-level keys explained: Notes on fields in this example:
  • apiVersion: v1 and kind: Pod are case-sensitive and must match the API object you want to create.
  • metadata.name uniquely identifies the Pod in the namespace.
  • metadata.labels are key/value tags used for grouping and selectors.
  • spec.containers is a YAML sequence (-) containing container definitions. Each container must have a unique name within the Pod and an image.
  • To use a private or non-Docker Hub registry, supply the full image path (for example, myregistry.example.com/myimage:tag). See Docker Hub and registry docs for authentication details.
Do not use tabs in YAML files — only spaces. Tabs will cause parsing errors. Also remember kubectl create -f will fail if the object already exists; kubectl apply -f is idempotent and is preferred for declarative workflows.
Saving tips:
  • In vim: press Escape, then type :wq to save and exit.
  • Validate indentation visually or with a YAML linter before applying.
Create the Pod with:
Example output:
Check Pod status. Immediately after creation you may see a transient ContainerCreating state while the image is pulled and the container is set up:
A short time later it should transition to Running once the image is pulled and the container starts:
Common Pod STATUS values: To inspect details (conditions, volumes, events, container statuses), run:
A trimmed example of the important sections from kubectl describe (conditions, volumes, QoS, tolerations, and events) might look like this:
Resources and further reading: That covers creating a Pod from a YAML manifest. Next, you can explore adding ports, environment variables, resource requests/limits, and probes to the Pod spec to make it production-ready.

Watch Video