kubectl apply

Apply a Kubernetes manifest to create or update resources.

medium risk

interactive breakdown — edit the command and press Explain
$ 
⚠ Risks & cautions
Safer / dry-run alternatives
kubectl diff -f manifest.yamlSee exactly what would change.
kubectl apply -f manifest.yaml --dry-run=serverValidate against the API server and admission webhooks.
What it does

kubectl apply declaratively applies resource manifests from files or directories. It creates resources if they don't exist, and updates them if they do — using server-side merge. Always dry-run first in production with --dry-run=server.

Common flags
FlagMeaning
-f --filenameFile, directory, or URL
-R --recursiveProcess directories recursively
--dry-runclient or server — preview without applying
--validateValidate manifest before applying
--forceForce apply by deleting and recreating
Examples
kubectl apply -f deployment.yamlApply a single manifest · explain & risk-check →
kubectl apply -f ./manifests/ -RApply all manifests in a directory · explain & risk-check →
kubectl apply -f deployment.yaml --dry-run=serverServer-side dry run (validates against API) · explain & risk-check →
kubectl apply -k ./overlays/productionApply Kustomize overlay · explain & risk-check →
Pro tip

Always use `--dry-run=server` not `--dry-run=client` — server-side dry run runs full validation including admission webhooks, catching errors that client-side validation misses.

Related
kubectl get kubectl describe helm
Open the full explainer →More in Kubernetes & Helm

Reference text is hand-written and may be incomplete — check man kubectl for your version. Test destructive commands on a non-production system first.