helm-diff icon indicating copy to clipboard operation
helm-diff copied to clipboard

Helm diff upgrade on non-Helm resources

Open gw0 opened this issue 3 years ago • 2 comments

I have a couple of Helm charts deployed as a rendered manifest via ArgoCD (i.e. without app.kubernetes.io/managed-by=Helm). I thought I could use the helm-diff plugin to check for differences between a local version of the chart and the live resources.

Unfortunately, it fails due to a sanity check that does not make sense during a diff action:

$ helm diff upgrade foo . --allow-unreleased --reset-values
reading three way merge from env
********************

	Release was not present in Helm.  Diff will show entire contents as new.

********************
Error: Failed to render chart: exit status 1: Error: rendered manifests contain a resource that already exists. Unable to continue with install: ConfigMap "foo" in namespace "default" exists and cannot be imported into the current release: invalid ownership metadata; label validation error: missing key "app.kubernetes.io/managed-by": must be set to "Helm"; annotation validation error: missing key "meta.helm.sh/release-name": must be set to "foo"; annotation validation error: missing key "meta.helm.sh/release-namespace": must be set to "default"

Error: plugin "diff" exited with error

There is no --force option to turn off all sanity checks and just fetch all the resources and run a diff on them. Setting HELM_DIFF_THREE_WAY_MERGE=false also does not help.

A workaround is to add these annotations to the live resources before each helm diff (but they get immediately reverted if ArgoCD self-healing is turned on):

$ kubectl annotate $KIND $NAME meta.helm.sh/release-name=$RELEASE
$ kubectl annotate $KIND $NAME meta.helm.sh/release-namespace=$NAMESPACE
$ kubectl label $KIND $NAME app.kubernetes.io/managed-by=Helm 

gw0 avatar Feb 10 '22 23:02 gw0

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 12 '22 14:06 stale[bot]

Still unresolved.

gw0 avatar Jun 13 '22 12:06 gw0

I also encountered this problem, my case is Argo CD + helmfile. I expect to use helmfile diff to see the changes directly when writing a chart locally, but the helm chart deployed by Argo CD has no annotations, so I can't use helmfile diff

xiaomudk avatar Dec 01 '22 03:12 xiaomudk

@databus23 @mumoshu Can you help me?

xiaomudk avatar Dec 01 '22 03:12 xiaomudk