java icon indicating copy to clipboard operation
java copied to clipboard

Kubectl should support cascading deletes for Jobs

Open gautam-rl opened this issue 1 year ago • 1 comments
trafficstars

Describe the bug Kubectl doesn't make it possible to delete a Job and have the delete cascade to the underlying pod. By default it appears to orphan the pod as described here: https://kubernetes.io/docs/concepts/workloads/controllers/job/#ttl-mechanism-for-finished-jobs.

Client Version 20.0.1

Kubernetes Version 1.29

Java Version Java 21

To Reproduce Create a job and then delete it using Kubectl:

Kubectl.delete(V1Job.class)
    .apiClient(client)
    .name(jobId)
    .namespace(namespace)
    .ignoreNotFound(true)
    .execute());

Expected behavior It should be possible to pass in .deleteOptions() and cascade or do foreground propagation.

Additional context As a workaround we can use the batchApi:

V1Status v1Status =
          batchApi.deleteNamespacedJob(jobId, namespace).propagationPolicy("Foreground").execute();

gautam-rl avatar Jun 04 '24 23:06 gautam-rl