How to find owner of cronjobs in Kubernetes and Kill it? How to find owner of cronjobs in Kubernetes and Kill it? kubernetes kubernetes

How to find owner of cronjobs in Kubernetes and Kill it?


These pods are managed by cronjob controller.

Use kubectl get cronjobs to list them.


If a Kubernetes object is created by a controller, then its owner is listed in the per-object metadata. You already see this in your Pod output:

# kubectl get pod hello-27125624-kc9zw -oyamlmetadata:  ownerReferences:  - apiVersion: batch/v1    blockOwnerDeletion: true    controller: true    kind: Job    name: hello-27125624    uid: 26beb7de-1c60-4854-a70f-54b6d066c22c

This same metadata format is used by every Kubernetes object. If there are no ownerReferences: then usually the object was directly created by a user (maybe via a tool like Helm or Kustomize).

If you similarly kubectl get job hello-27125624 -o yaml you will probably see a similar ownerReferences: block with apiVersion: batch/v1, kind: CronJob, and a specific name:. That object is probably user-managed and that's the object to delete.