argoproj/gitops-engine

Add annotation `argocd.argoproj.io/sync-options: Force=true`

jiwonaid opened this issue · 9 comments

Summary

This issue is about the need for the new annotation argocd.argoproj.io/sync-options: Force=true, which is needed for the use case like the job resources that should run every time when syncing.

Goals & Proposal

Could we implement the new annotation feature on this repo?

Based on kubectl replace --help, --force is needed to delete and then re-create the resources.

~  kubectl replace --help
  
  # Force replace, delete and then re-create the resource
  kubectl replace --force -f ./pod.json
  

Currently, there is nothing like argocd.argoproj.io/sync-options: Force=true.
It seems like argocd.argoproj.io/sync-options: Replace=true runs on this library.

func WithReplace(replace bool) SyncOpt {
return func(ctx *syncContext) {
ctx.replace = replace
}
}

Releated Issues

There are some related issues at argo-cd repo. Please take a look.
argoproj/argo-cd#5882
argoproj/argo-cd#7459
argoproj/argo-cd#9163

Thank you for reading.

Any progress with this enhancement?

Hi @jelical,
I am not sure argocd's current status, and not working on this.

Anyone who would like to push this forward can take this.

Thank you.

Is there a way in ArgoCD to do this currently?

@crenshaw-dev @gdsoumya @alexec I think this is an absolutely critical feature, so would appreciate your feedback.

Currently, ArgoCD doesn't have a way to use kubectl apply --force or kubectl replace --force, and this is required to update some common types of Kubernetes resources, like Jobs and CronJobs and even bare Pods.

The solution posed here is very elegant, as it allows users to specifically annotate argocd.argoproj.io/sync-options: Replace=true,Force=true on resources that they know can't be updated without being deleted first.

@thesuperzapper I agree! I believe the open PR just needs some unit test work.

@crenshaw-dev I assume you are talking about this PR: #526

Correct