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
• 11,590 points
52 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
• 55,530 points

Related Questions In Kubernetes

0 votes
2 answers
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
• 51,890 points
1,761 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, 2019 in Others by anonymous
7,606 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 11, 2019 in Kubernetes by Kalgi
• 51,890 points

reshown Apr 12, 2019 by Kalgi 2,233 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
• 55,530 points
1,288 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
• 55,530 points
1,252 views