YAML Diff · Tutorial
How to compare staging and production YAML before a release
6 min readbeginnerUpdated
Staging works, production is about to get the same release, and the two values files differ in ways nobody remembers. This tutorial compares them with YAML Diff, separates real changes from list items that only moved, and gives you a short, exact list of what production will get.
What you need
- The YAML Diff tool
- Two YAML files for the same app, for example Helm values or Compose files for two environments (the Try it button loads a staging and a production values file)
Steps
Paste both files
Put the staging file on the left as Original and the production file on the right as Changed. Comments, key order and indentation don't count, so you can paste them as they are.
Read the summary
The sample shows 11 differences. Each one is highlighted in both boxes, amber for changed values and green for added ones, so you can see where they are without reading the files line by line.
Ignore list items that only moved
Two of those differences are noise. The
env:list has the same variables in a different order, so position by positionnamelooks swapped. Tick Ignore order of array items. Variables are now matched by theirname, the count drops to 9 and the note says 2 order-only changes were removed.~ $.env[0].value (was $.env[1].value): "300" → "600" ~ $.env[1].value (was $.env[0].value): "debug" → "info" + $.env[2]: {"name":"SENTRY_DSN", …}Check each real change
Click a path in the Changes list to jump to it. In the sample, production gets a newer image tag, twice the replicas, CPU and memory, a longer cache, quieter logging, a new
SENTRY_DSNvariable and TLS on a different host. Make sure each one is intended.Share the list
Press Copy change list and paste it into the release notes or the pull request, so reviewers see exactly which settings differ.
Try it yourself
Opens the YAML Diff with this tutorial's sample loaded.
Common mistakes
- Comparing the wrong pair of files
- Compare files for the same chart or service. Two unrelated files differ almost everywhere, and the list stops being useful.
- Expecting comment changes in the list
- Comments aren't data, so they are never reported. Use a text diff if a comment change matters to you.
- Leaving "Ignore order" on for ordered lists
- Some lists do depend on order, like init containers or middleware. Keep the option off for those, so a reorder shows up as a change.
Next steps
Go back to the YAML Diff, or keep going with one of these:
FAQ
Can I compare files with several documents?
Yes. A file with several --- documents is compared document by document, with paths such as $[1].spec.replicas.
Why is a value I changed from 300 to "300" reported?
Because the type changed, from a number to a string. Many tools treat them differently, so the diff reports it.