Kubernetes provides a activeDeadlineSeconds
field for both JobSpec
and PodSpec
What is the difference between the two? I've put together a little job with activeDeadlineSeconds
set to 20, and in its Pod definition I have set the activeDeadlineSeconds
field to 45. These are kind of arbitrary but meant to be spaced out. When I create/apply the Job then run kubectl get pods -a --watch
, I can see that the 20 deadline isn't having any effect but the second one is (I see the DeadlineExceeded
output).
Just to be extra certain, I added terminationGracePeriodSeconds: 10
in the PodSpec and see the same thing.
What is the purpose of the activeDeadlineSeconds
in the Job? It doesn't seem to be sending any signal to my container.
Note: I'm simply running the sleep
command on an ubuntu
image. This command should exit when receiving the TERM signal sent by Kubernetes (so I expect a TERM signal at 20 seconds then the pod to die shortly thereafter)
Condensed YAML definition:
apiVersion: batch/v2alpha1 # K8s 1.7.x
kind: CronJob
spec:
schedule: "*/1 * * * *"
concurrencyPolicy: Allow
jobTemplate:
spec: # JobSpec
activeDeadlineSeconds: 20 # This needs to be shorter than the cron interval ## TODO - NOT WORKING!
parallelism: 1
template: # PodTemplateSpec
spec:
activeDeadlineSeconds: 45
terminationGracePeriodSeconds: 10
containers:
- name: ubuntu-container
image: ubuntu
command: ['bash', '-c', 'sleep 500000']
References:
Community wiki answer for future:
As per @Clorichel this issue was fixed in k8s v1.8 https://github.com/kubernetes/kubernetes/issues/32149
My advice is to upgrade your cluster to the latest version, if is possible to have access to newest features and bug fixes.