I am running thousands of job in rancher using rancher CLI. I want to delete the job as soon as the task is finished. THe problem is When the job finishes the job remain "Active" there.
I tried suggestion from How to automatically remove completed Kubernetes Jobs created by a CronJob? but its not working for me. As i can see the underlying docker container gets into "Terminated" state but the deployed job remains active.
Right now i have to synchronously wait for job to finish and then i am firing "kubectl delete" command to delete job. But i want to do that asynchronously(delete all job that are "done").
Any idea?
Update
Here is the yaml file for my job
apiVersion: batch/v1
kind: Job
metadata:
name: runtest
namespace: default
spec:
ttlSecondsAfterFinished: 60
template:
metadata:
labels:
job-name: runtest
spec:
restartPolicy: Never
containers:
- args:
- sh
- /code/rancher_test/run_9.sh
image: x11vnc/docker-desktop
name: runtest
stdin: true
tty: true
securityContext:
runAsUser: 53197
volumeMounts:
- mountPath: /code
name: code
volumes:
- hostPath:
path: /code
type: ""
name: code