How can I deploy/sync a Job resource with Argo CD? #7984
-
My question is: Can we sync Job resources with Argo CD? If yes, do you have any hints or links to samples for how to do it? I tried with Argo CD
Any ideas what I am doing wong? (I am still new to Argo). Argo version: v2.1.7 here is the simple Job I used for testing this apiVersion: batch/v1
kind: Job
metadata:
name: jobtest
spec:
backoffLimit: 1
completions: 1
template:
spec:
containers:
- name: jobtest
image: busybox
command: ["echo", "This is the changed test job"]
restartPolicy: Never here is my application apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: debug-job
namespace: argocd
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
project: explorer
destination:
namespace: dev
server: https://kubernetes.default.svc
source:
path: debug-job
repoURL: https://github.example.com/myrepo.git
targetRevision: HEAD
syncPolicy:
automated:
prune: true
syncOptions:
- Replace=true
retry:
limit: 1
backoff:
duration: 5s
factor: 2
maxDuration: 30s Here is the error of the 2nd attempt:
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 6 replies
-
Hm. I'd dare to say that Kubernetes I'd suggest to make your |
Beta Was this translation helpful? Give feedback.
-
That might be the |
Beta Was this translation helpful? Give feedback.
-
Using sync hook(Sync) with deletion policy(Success) do work but it also delete the job from the ArgoUI, let's say, I have multiple jobs from one application and I want only rerun one of the jobs from the UI, how can I do that? |
Beta Was this translation helpful? Give feedback.
-
I'll close this as the original question is quite old and got answered back then. Please, open new questions instead. |
Beta Was this translation helpful? Give feedback.
Hm. I'd dare to say that Kubernetes
Jobs
are classical one time events. You deploy aJob
into your cluster, it will run and afterwards be terminated - it can't be re-run. Probably due to this fact, lots of fields in theJob
spec are immutable and can't be changed once the resource exists in your cluster. Also, this makes it a quite ungrateful resource for being managed in a GitOps way.I'd suggest to make your
Job
a sync hook, with a proper deletion policy (e.g.BeforeHookCreation
), so that the Job will be deleted and re-created on every sync. If you have no other resources for your application that could sync, maybe you can just create aConfigMap
(with a timestamp or similar property) f…