How do you preview exactly what a kubectl apply will change before applying it?
⚡
Quick Answer
Use kubectl diff -f manifest.yaml. It shows a diff between your manifest and the live cluster state (server-side dry run), so you see precisely what will change before you commit.
Detailed Answer
kubectl diff performs a server-side dry-run apply and prints the resulting differences, catching surprises (a field another controller owns, an unintended replicas change) before they hit production. Pair it with kubectl apply --dry-run=server to validate without persisting. It is the safe habit before any manual apply.
Code Example
kubectl diff -f deployment.yaml
💡
Interview Tip
Note it is a server-side dry run (so it reflects defaulting/admission), and pairing it with --dry-run=server for validation.
kuberneteskubectldiffgitops