No description
Find a file
2026-09-04 11:19:07 +02:00
diff-beautifier.py Initial 2026-09-04 11:16:19 +02:00
Readme.md Typo 2026-09-04 11:19:07 +02:00

Kubectl diff beautifier

kubectl diffis a good command to see the diffs of a new rollout in gitops scenarios. The output is sometimes a little bit complicated and not so easy to read.

diff-beautifier.py is a small tool which takes the diff output from a kubectl diff command, splits the output in parts (every object is a section) and generates a markdown file with the changes.

This works also with complex rollouts like embedding helm charts in kustomize content where it's not so easy to see which consequences will arise from your changes.

Usage

kubectl diff -f myasset.yaml | diff-beautifier.py generates a markdown on stdout with the changes myasset.yaml would make to my namespace/cluster.

Here's the usage:

usage: diff-beautifier.py [-h] [--output OUTPUT] [--header HEADER]

Format kubectl diff output to Markdown

options:
  -h, --help           show this help message and exit
  --output, -o OUTPUT  Output file path (default: stdout)
  --header, -H HEADER  Custom level 1 header text (default: "Kubernetes Configuration Diff")

A more complex and advanced example. You have a kustomization.yaml with embedded helm chart rendering in directory ./deployment/ and want the output generated as Changes.md with date appended:

nowdate=$(date "+%F")
kubectl kustomize --enable-helm ./deployment/  \
  | kubectl diff -f - \
  | diff-beautifier -o Changes${nowdate}.md -H "Changes on ${nowdate} from ./deployment/"

If you push these after the command you get a history in your deployment repo ;-)


Peter Pfläging peter@pflaeging.net