-
Notifications
You must be signed in to change notification settings - Fork 111
Deleting an Object which created a Job does not delete the pods created by that job #342
Description
What happened?
I have a Composition that creates an Object which creates a Job. When the Object is deleted the Job is deleted but the Pods which were created to execute the Job are not deleted. The expected behavior is that deleting the Object will also delete the Pods since this is what happens when a Job is deleted manually. This does not happen when using a Deployment instead of a Job, in that case Pods are deleted when the Deployment is deleted by way of deleting the Object
How can we reproduce it?
- Create this
Object
This job will exit with a random code between 0 and 5 to simulate a job which needs to retry a few times which is the case for the real job in my Composition.
apiVersion: kubernetes.crossplane.io/v1alpha2
kind: Object
metadata:
name: test-job
spec:
references:
forProvider:
manifest:
apiVersion: batch/v1
kind: Job
metadata:
name: test-job
namespace: default
spec:
template:
spec:
containers:
- name: busybox
image: busybox
command: ["/bin/sh", "-c", "exit $((RANDOM % 6))"]
imagePullPolicy: IfNotPresent
restartPolicy: Never- Allow it to create a few pods. It does not matter whether or not any complete successfully, the behavior is the same.
- Delete the
Object. Observe that theJobis deleted but allPodsfor the job are still there - Create this
Object
apiVersion: kubernetes.crossplane.io/v1alpha2
kind: Object
metadata:
name: test-deploy
spec:
references:
forProvider:
manifest:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
namespace: default
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80- Allow it to create its pods
- Delete the
Object. Observe that theDeploymentis deleted and allPodsfor the deployment are deleted
What environment did it happen in?
Crossplane version: 1.19.0
Provider version: 0.17.0
Kubernetes version: v1.30.9-gke.1046000
Kubernetes distribution: Google Kubernetes Engine (GKE)