cancel
Showing results for 
Search instead for 
Did you mean: 
magoyal
Flight Engineer Flight Engineer
Flight Engineer
  • 1,523 Views

cronjob.spec.jobTemplate.spec.completions not working in kubernetes

 

I have a doubt regarding CronJob in Kubernetes. Here I am using completions option in this YAML file under CronJob.spec.jobTemplate.spec and I can see that completions option is not working at all. I thought the job will run 5 times only then it will stopped but the job is continuously running (Please see the logs) so I want know why it is so? CronJob option is accepting completions options then it should work :/

P.S:- Parallelism option is wroking well tough. Also in case of Job.spec.template.spec completions option is working well.

 

Yaml File:-

kind:     CronJob
apiVersion:  batch/v1beta1
metadata:
 name: sample-cron-job
spec:
 schedule: "*/1 * * * *"
 jobTemplate:
   spec:
     completions: 5
     parallelism: 2
     template:
       spec:
         containers:
           - name: cont
             image: alpine
             command: ["/bin/sleep"]
             args: ["180"]
         restartPolicy: Never

Logs:-

 

NAME                               READY   STATUS      RESTARTS   AGE     IP            NODE       NOMINATED NODE   READINESS GATES         
sample-cron-job-1591543860-72c47   0/1     Completed   0          9m35s   172.17.0.15   minikube   <none>           <none>         
sample-cron-job-1591543860-dhnfg   0/1     Completed   0          9m27s   172.17.0.25   minikube   <none>           <none>         
sample-cron-job-1591543860-dxz7f   0/1     Completed   0          12m     172.17.0.15   minikube   <none>           <none>         
sample-cron-job-1591543860-f4r6g   0/1     Completed   0          12m     172.17.0.25   minikube   <none>           <none>         
sample-cron-job-1591543860-wjhmk   0/1     Completed   0          5m57s   172.17.0.15   minikube   <none>           <none>         
sample-cron-job-1591543920-47vk8   0/1     Completed   0          11m     172.17.0.19   minikube   <none>           <none>         
sample-cron-job-1591543920-4dhnj   0/1     Completed   0          5m19s   172.17.0.10   minikube   <none>           <none>         
sample-cron-job-1591543920-bdxbd   0/1     Completed   0          8m35s   172.17.0.10   minikube   <none>           <none>         
sample-cron-job-1591543920-f5qsk   0/1     Completed   0          8m27s   172.17.0.19   minikube   <none>           <none>         
sample-cron-job-1591543920-fcspj   0/1     Completed   0          11m     172.17.0.10   minikube   <none>           <none>         
sample-cron-job-1591543980-969sd   0/1     Completed   0          7m32s   172.17.0.20   minikube   <none>           <none>         
sample-cron-job-1591543980-chkxm   0/1     Completed   0          10m     172.17.0.17   minikube   <none>           <none>         
sample-cron-job-1591543980-f2lrx   0/1     Completed   0          7m19s   172.17.0.17   minikube   <none>           <none>         
sample-cron-job-1591543980-gqjh9   0/1     Completed   0          10m     172.17.0.20   minikube   <none>           <none>         
sample-cron-job-1591543980-rqx6r   0/1     Completed   0          4m21s   172.17.0.20   minikube   <none>           <none>         
sample-cron-job-1591544040-59rlh   0/1     Completed   0          9m44s   172.17.0.12   minikube   <none>           <none>         
sample-cron-job-1591544040-b445v   0/1     Completed   0          6m17s   172.17.0.24   minikube   <none>           <none>         
sample-cron-job-1591544040-p2485   1/1     Running     0          3m9s    172.17.0.23   minikube   <none>           <none>         
sample-cron-job-1591544040-wjh9w   0/1     Completed   0          6m6s    172.17.0.12   minikube   <none>           <none>         
sample-cron-job-1591544040-xwsr2   0/1     Completed   0          9m44s   172.17.0.24   minikube   <none>           <none>         
sample-cron-job-1591544100-6hwjn   0/1     Completed   0          5m25s   172.17.0.16   minikube   <none>           <none>         
sample-cron-job-1591544100-hpzzm   0/1     Completed   0          8m43s   172.17.0.18   minikube   <none>           <none>         
sample-cron-job-1591544100-lbrz4   0/1     Completed   0          8m43s   172.17.0.16   minikube   <none>           <none>         
sample-cron-job-1591544100-pln5k   1/1     Running     0          2m17s   172.17.0.9    minikube   <none>           <none>         
sample-cron-job-1591544100-plstw   0/1     Completed   0          5m31s   172.17.0.9    minikube   <none>           <none>         
sample-cron-job-1591544160-849hq   0/1     Completed   0          4m36s   172.17.0.14   minikube   <none>           <none>         
sample-cron-job-1591544160-fw5pf   0/1     Completed   0          4m28s   172.17.0.19   minikube   <none>           <none>         
sample-cron-job-1591544160-jrj2g   0/1     Completed   0          7m43s   172.17.0.22   minikube   <none>           <none>         
sample-cron-job-1591544160-nwpqc   1/1     Running     0          80s     172.17.0.14   minikube   <none>           <none>         
sample-cron-job-1591544160-p8sqm   0/1     Completed   0          7m43s   172.17.0.14   minikube   <none>           <none>         
sample-cron-job-1591544220-7h4zs   0/1     Completed   0          3m33s   172.17.0.11   minikube   <none>           <none>         
sample-cron-job-1591544220-gpnpx   0/1     Completed   0          6m43s   172.17.0.21   minikube   <none>           <none>         
sample-cron-job-1591544220-m9cxn   0/1     Completed   0          3m26s   172.17.0.21   minikube   <none>           <none>         
sample-cron-job-1591544220-rv8dz   0/1     Completed   0          6m43s   172.17.0.11   minikube   <none>           <none>         
sample-cron-job-1591544220-xvrjr   1/1     Running     0          18s     172.17.0.11   minikube   <none>           <none>         
sample-cron-job-1591544280-9jgxm   1/1     Running     0          2m27s   172.17.0.25   minikube   <none>           <none>         
sample-cron-job-1591544280-cdvhh   0/1     Completed   0          5m43s   172.17.0.26   minikube   <none>           <none>         
sample-cron-job-1591544280-kpv7r   0/1     Completed   0          5m43s   172.17.0.25   minikube   <none>           <none>         
sample-cron-job-1591544280-r46sd   1/1     Running     0          2m35s   172.17.0.24   minikube   <none>           <none>         
sample-cron-job-1591544340-27v4m   1/1     Running     0          87s     172.17.0.13   minikube   <none>           <none>         
sample-cron-job-1591544340-4qvfs   1/1     Running     0          94s     172.17.0.18   minikube   <none>           <none>         
sample-cron-job-1591544340-6k99d   0/1     Completed   0          4m43s   172.17.0.18   minikube   <none>           <none>         
sample-cron-job-1591544340-mk2lg   0/1     Completed   0          4m43s   172.17.0.13   minikube   <none>           <none>         
sample-cron-job-1591544400-4j8jh   0/1     Completed   0          3m43s   172.17.0.17   minikube   <none>           <none>         
sample-cron-job-1591544400-9mls2   1/1     Running     0          25s     172.17.0.22   minikube   <none>           <none>         
sample-cron-job-1591544400-bk8pm   0/1     Completed   0          3m43s   172.17.0.22   minikube   <none>           <none>         
sample-cron-job-1591544400-q4w9x   1/1     Running     0          32s     172.17.0.17   minikube   <none>           <none>         
sample-cron-job-1591544460-9kvlr   1/1     Running     0          2m42s   172.17.0.12   minikube   <none>           <none>         
sample-cron-job-1591544460-c7v8n   1/1     Running     0          2m42s   172.17.0.15   minikube   <none>           <none>

 

 

Labels (2)
0 Kudos
0 Replies
Join the discussion
You must log in to join this conversation.