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, 2019 in Kubernetes by Karan
• 19,610 points
1,345 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, 2019 by Sirajul
• 59,230 points

Related Questions In Kubernetes

0 votes
1 answer
0 votes
1 answer

I am not able to set static IP for my ubuntu VM.... I am referring Kubernetes installation!

Hey, check this out for the steps ...READ MORE

answered Sep 28, 2020 in Kubernetes by Vishwanath Deshpande

edited Oct 6, 2021 by Sarfaraz 754 views
0 votes
2 answers

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

if u want to directly want to ...READ MORE

answered Jul 26, 2020 in Kubernetes by Akash Gupta
1,318 views
+1 vote
1 answer
0 votes
3 answers

Error while joining cluster with node

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

answered Jan 17, 2019 in Others by anonymous
15,477 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,035 views
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, 2019 in Kubernetes by Sirajul
• 59,230 points
7,684 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, 2019 in Kubernetes by Sirajul
• 59,230 points
2,807 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP