Skip to content

Instantly share code, notes, and snippets.

@haraldsk
Created October 28, 2021 12:39
Show Gist options
  • Save haraldsk/7fdd6b16623503795aa14e70d2b111cc to your computer and use it in GitHub Desktop.
Save haraldsk/7fdd6b16623503795aa14e70d2b111cc to your computer and use it in GitHub Desktop.
Safely diff helm charts between two cluster contexts
#!/usr/bin/env bash
set -o errexit
set -o nounset
# ./diff-helm $chart $namespace
CHART=${1}
NAMESPACE=${2}
CTX_ONE="coronita"
CTX_TWO="corona"
OBJECTS="all" # all, manifest, values
DIFF_CMD="/opt/homebrew/bin/diff --color -urN" # needs gnu diffutils - brew install diffutils
CTX_ONE_FILE=$(mktemp)
CTX_TWO_FILE=$(mktemp)
trap "rm -f $CTX_ONE_FILE $CTX_TWO_FILE" EXIT
HELM_KUBECONTEXT=$CTX_ONE helm get manifest $CHART -n $NAMESPACE > $CTX_ONE_FILE
HELM_KUBECONTEXT=$CTX_TWO helm get manifest $CHART -n $NAMESPACE > $CTX_TWO_FILE
$DIFF_CMD $CTX_ONE_FILE $CTX_TWO_FILE
@AtzeDeVries
Copy link

AtzeDeVries commented Oct 28, 2021

you can use stdout in diffs if you want

diff <(echo bla) <(echo blad)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment