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
949 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 537 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,075 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
14,572 views
+4 votes
1 answer

Installing Web UI (Dashboard):kubernetes-dashboard on main Ubuntu 16.04.6 LTS (Xenial Xerus) server

Follow these steps: $ kubeadm reset $ kubeadm init ...READ MORE

answered Apr 12, 2019 in Kubernetes by Kalgi
• 52,360 points

reshown Apr 12, 2019 by Kalgi 6,050 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,025 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,531 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