apply
What is apply?
apply: Create or update resources from a manifest, declaratively. Kubernetes diffs your file against the live state and reconciles. kubectl apply creates or updates Kubernetes resources from a manifest file. You describe the desired state, such as three replicas of an image with these settings, and Kubernetes works out what to change.
Frequently asked questions about apply
How is apply used in practice?
This is the declarative approach. You do not say "start two more pods". You say "there should be three", and Kubernetes reconciles the difference. Running the same apply twice changes nothing the second time.
What should you keep in mind with apply?
Keep your manifests in Git, so every change is reviewed and recorded. Use kubectl diff -f before apply to see what would change, and --dry-run=server to check the manifest without applying it. Tools like Kustomize and Helm build on apply, and GitOps tools such as Argo CD run it for you whenever the repository changes.
What does an example of apply look like?
kubectl apply -f deployment.yaml kubectl apply -k ./overlays/prod At a glance
| Category | Kubernetes |
|---|---|
| Explained by | Reinier de la Parra |
| Updated |