kubectl instead of using kubectl run. Using a manifest gives you a reproducible, versionable definition you can store in source control.

- Author a Pod manifest in YAML.
- Apply it with
kubectl apply -f pod.yaml. - Inspect the Pod with
kubectl getandkubectl describe.
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.
pod.yaml. It uses the four required top-level keys for a basic Pod: apiVersion, kind, metadata, and spec.
Notes on fields in this example:
apiVersion: v1andkind: Podare case-sensitive and must match the API object you want to create.metadata.nameuniquely identifies the Pod in the namespace.metadata.labelsare key/value tags used for grouping and selectors.spec.containersis a YAML sequence (-) containing container definitions. Each container must have a uniquenamewithin the Pod and animage.- 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.- In
vim: press Escape, then type:wqto save and exit. - Validate indentation visually or with a YAML linter before applying.
ContainerCreating state while the image is pulled and the container is set up:
Running once the image is pulled and the container starts:
To inspect details (conditions, volumes, events, container statuses), run:
kubectl describe (conditions, volumes, QoS, tolerations, and events) might look like this: