<pre class="lang-golang prettyprint-override"><code>// Delete a Batch Job by name
func (k K8sClient) DeleteBatchJob(name string, namespace string) error {
    return k.K8sCS.BatchV1().Jobs(namespace).Delete(context.TODO(), name, metav1.DeleteOptions{})
}
</code></pre>
<p>I am deleting a job if already exists and then starting a new Job, but the operation here is asynchronous and job creation phase started when the job is being deleted, which I don't want.
I want to successfully delete a job before creation of new one.</p>
<p>How can I implement this functionality using go?</p>

Abhishek Kumar
<p>If you give every job a unique name, you won't have to wait for the asynchronous deletion to make a new one.  This is how the cron scheduler works in k8s - it creates uniquely named jobs every time.</p>
<p>To find and manage the jobs, you can use labels instead of the job name.</p>
