From the docs we can see this text:
https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/#job-termination-and-cleanup
"When you delete the job using kubectl, all the pods it created are deleted too."
But my testing shows this is not the case going through the go client:
https://github.com/kubernetes/client-go/blob/master/kubernetes/typed/batch/v1/job.go#L140
Is this expected, in that I should clean up the pods manually?
when you delete via client-go, set a propagation policy in the delete options if you want the child pods to be deleted as well.
/close
@liggitt: Closing this issue.
In response to this:
when you delete via client-go, set a propagation policy in the delete options if you want the child pods to be deleted as well.
/close
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
Thanks @liggitt
I now see that I missed this optional field. For future readers here is the doc on foreground vs background deletion [1]
// Whether and how garbage collection will be performed.
// Either this field or OrphanDependents may be set, but not both.
// The default policy is decided by the existing finalizer set in the
// metadata.finalizers and the resource-specific default policy.
// Acceptable values are: 'Orphan' - orphan the dependents; 'Background' -
// allow the garbage collector to delete the dependents in the background;
// 'Foreground' - a cascading policy that deletes all dependents in the
// foreground.
// +optional
PropagationPolicy *DeletionPropagation `json:"propagationPolicy,omitempty" protobuf:"varint,4,opt,name=propagationPolicy"`
[1] https://kubernetes.io/docs/concepts/workloads/controllers/garbage-collection/#controlling-how-the-garbage-collector-deletes-dependents
Most helpful comment
Thanks @liggitt
I now see that I missed this optional field. For future readers here is the doc on foreground vs background deletion [1]
[1] https://kubernetes.io/docs/concepts/workloads/controllers/garbage-collection/#controlling-how-the-garbage-collector-deletes-dependents