Create or update resources from a YAML file.

Section: Manifest Basics

Apply YAML file

bash
bash
kubectl apply -f app.yaml
Explanation

`kubectl apply` accepts YAML or JSON and creates the resource if it does not exist yet. `kubectl diff -f ...` is useful before applying changes.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Manifest Basics
Apply YAML directory
Apply all manifests in a directory.
OpenIn sheetbashsame section
Preview manifest changes
See what apply would change.
OpenIn sheetbashsame section
Minimal Pod manifest
Smallest practical Pod YAML shape.
OpenIn sheetyamlsame section
Multiple resources in one YAML file
Separate resources with `---`.
OpenIn sheetyamlsame section
Get resources by label selector
Use labels to query related objects.
OpenIn sheetbash1 tag match
Explain a field path
Discover valid YAML fields from kubectl.
OpenIn sheetbash1 tag match