-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
argocd app diff for app-of-apps #4706
Comments
Also the current diff behaviour only works for changes to the chart, it doesn't work for changes to |
We also have this scenario where an application was already deployed in the cluster with helm. We wanted to manage it with ArgoCD. We first create just the application ( Now that the application is in ArgoCD, if you run:
I expect it to show only the minimal diff since the helm chart is already deployed. Instead, the |
@musabmasood I guess this is the expected behavior? You had just an App without a chart deployed, so the live state that ArgoCD is aware of is empty (i.e. there were no resources marked as being part of the App). In your branch you had added the chart, so the target state contains all the resources. The difference is to apply them all (which would probably just add some annotations, but leave them as-is). |
Oh, I found a manual workaround for the OP issue... So, the goal is to get a diff on all manifests generated by an App when you make a local change to the App manifest.
|
Lets script this workaround: $ APP_NAME="my-app"
## render root and extract the modified App
$ kustomize --enable-helm --load-restrictor=LoadRestrictionsNone my-root/ > root-local.yaml
$ yq "[.] | select(.[].metadata.name==\"${APP_NAME}\") | .[0]" root-local.yaml > modified.yaml
## create a temporary modified App with disabled finalizers and sync
$ yq -i '.metadata.name="tmp-modified" | del(.metadata.finalizers) | del(.spec.syncPolicy.automated)' modified.yaml
$ argocd app create -f modified.yaml
## render all manifests by the current App and the modified App
$ argocd app manifests "${APP_NAME}" --source=git > all-current.yaml
$ argocd app manifests tmp-modified --source=git > all-modified.yaml
## remove the temporary modified App
$ argocd app delete -y tmp-modified
## clean-up
$ YQ_FILTER='
del(.metadata.creationTimestamp) |
del(.metadata.generation) |
del(.metadata.resourceVersion) |
del(.metadata.uid) |
del(.metadata.managedFields) |
del(.metadata.annotations."kubectl.kubernetes.io/last-applied-configuration") |
del(.metadata.annotations."deployment.kubernetes.io/revision") |
del(.metadata.labels."app.kubernetes.io/instance") |
del(.status)
' \
GREP_FILTER='^\{\}$|^ annotations: \{\}$|^ labels: \{\}$| vault/last-refresh:'
$ yq "${YQ_FILTER}" all-current.yaml | egrep -v "${GREP_FILTER}" > all-current-cleanup.yaml
$ yq "${YQ_FILTER}" all-modified.yaml | egrep -v "${GREP_FILTER}" > all-modified-cleanup.yaml
## diff
$ diff -u --color all-current-cleanup.yaml all-modified-cleanup.yaml |
Currently what I'm doing is having a python script that loops over all the modified manifests and then runs argocd diff against them. For remote charts, the script downloads it to a tmp directory and runs the diff with |
@jessesuen I'm interested in picking this up and running with it. Is there any issue with that? |
Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
I gave it a try: #12813 My current implementation requires |
I'm happy to see active development on this issue, but I do have question in case I can make a similar workaround in the meantime. My
The hash in I can appreciate if you don't want random workaround code floating around, but I'd like to take a peek at a gist if you can make one with your script! |
Afaik it needs to point to the local copy of the Helm chart itself (not Application resource). |
Also came across this issue. For this, I propose for a new flag like argocd app diff my-app --helm-values ./values.yaml Edit: After some thought, I think it would be better if the
The point is, I expect |
I'll try to help with the implementation |
I noticed |
Summary
argocd app diff --new-application-file app.yaml
should give a diff of what would be generated for a change to an Application objectMotivation
I'm trying to build a CI pipeline using the app-of-apps pattern, so my git repo contains a bunch of yaml files each of which contains an Application definition. The root app applies this whole directory.
I want to be able to (pre-merge, in a PR), get a diff of the actual changes that would happen, so I want to be able to run a command and pass it a file (or directory would also work), and generate the diff of what would be generated from the new Application object vs the one on the cluster. The current
argocd app diff --local
is very hard to use, because these charts are all being pulled from helm repositories (some internal, some external), so I don't have a convenient chart directory that's matching the version the new application is trying to install.Proposal
New CLI flags / command?
The text was updated successfully, but these errors were encountered: