argoproj / argo-cd

Declarative Continuous Deployment for Kubernetes
https://argo-cd.readthedocs.io
Apache License 2.0
17.93k stars 5.46k forks source link

Run hook only when specific path in the yaml was changed #13528

Open vvatlin opened 1 year ago

vvatlin commented 1 year ago

This is only my case but maybe it will be useful to have such feature.

I need to drop database during deployment, I use "hook"

annotations:
    argocd.argoproj.io/hook: PreSync
    argocd.argoproj.io/hook-delete-policy: BeforeHookCreation

But when I manually sync, or for example when I have auto sync and I want to change something in the yaml files , my database also will be dropped.

Maybe it's a good idea to have something like "path" or "field" which will be checked to decide whether to run hook or not. For example if spec.template.spec.containers[0].image or metadata.annotations.buildId was changed , then run the hook .

In this case we can be sure that only when we do "real" deployment our hook will run.

vvatlin commented 1 year ago

@alexmt @jannfis sorry to disturb you. But do you think it would be a good feature ?