Can I configure my kubernetes job to run for a specified time?

0 votes
I have a kubernetes job that should run for 40 seconds ideally but sometimes its taking almost 5 minutes to execute.How can i ensure that the application stops if it exceeds 40 seconds? Please help.
Jul 17 in Kubernetes by Karan
• 1,780 points
21 views

1 answer to this question.

0 votes

When we create a job spec, we can give --activeDeadlineSeconds  flag to the command. 

This flag relates to the duration of the job, once the job reaches the threshold specified by the flag, the job will be terminated.


kind: CronJob
apiVersion: batch/v1beta1
metadata:
  name: mycronjob
spec:
  schedule: "*/1 * * * *"
activeDeadlineSeconds: 200
  jobTemplate:
    metadata:
      name: google-check-job
    spec:
      template:
        metadata:
          name: mypod
        spec:
          restartPolicy: OnFailure
          containers:
            - name: mycontainer
             image: alpine
             command: ["/bin/sh"]
             args: ["-c", "ping -w 1 google.com"]
answered Jul 17 by Sirajul
• 25,220 points

Related Questions In Kubernetes

0 votes
1 answer

How can I access a service installed on Kubernetes from anywhere?

I have followed the link which you have ...READ MORE

answered Jul 23, 2018 in Kubernetes by Atul
• 10,240 points
132 views
0 votes
1 answer

image can't be pulled error when I try to pull a docker image - kubernetes

I think the image is being pulled ...READ MORE

answered Sep 4, 2018 in Kubernetes by Kalgi
• 40,440 points
526 views
0 votes
1 answer
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17 in Others by anonymous
2,096 views
+3 votes
1 answer
0 votes
1 answer

Can i configure my kubernetes pod to use multiple service accounts ?

A service account provides an identity for ...READ MORE

answered Jul 17 in Kubernetes by Sirajul
• 25,220 points
47 views
0 votes
1 answer

Configure a Kubernetes-pod to use persistent volume for storage.

The output shows that the PersistentVolume has ...READ MORE

answered Jul 23 in Kubernetes by Sirajul
• 25,220 points
293 views