How to set a time limit for a Kubernetes job?

I’d like to launch a Kubernetes job and give it a fixed deadline to finish. If the pod is still running when the deadline comes, I’d like the job to automatically be killed.

Does something like this exist? (At first I thought that the Job spec’s activeDeadlineSeconds covered this use case, but now I see that activeDeadlineSeconds only places a limit on when a job is re-tried; it doesn’t actively kill a slow/runaway job.)

  • How to npm install a private github repo from my own organization?
  • Establish PSSession to Windows docker container from remote machine (not container host)
  • What process signal does pod receive when executing `kubectl rolling-update`?
  • No suitable driver found (jdbc:pgsql)
  • Running nginx as proxy for gitlab in docker
  • docker-compose rails app doesn't find db when using up but does when doing run
  • Docker run tomcat errors
  • Mounted docker volume to host directory contains only files from the last container
  • Docker Plugin for Jenkins error: Scripts not permitted to use method
  • Dockerized Node js app does not start
  • How to remove all Docker containers
  • docker > run two nodejs scripts using gulp and nodemon
  • One Solution collect form web for “How to set a time limit for a Kubernetes job?”

    You can self-impose timeouts on the container’s entrypoint command by using GNU timeout utility.

    For example the following Job that computes first 4000 digits of pi will time out after 10 seconds:

    apiVersion: batch/v1
    kind: Job
      name: pi
          name: pi
          - name: pi
            image: perl
            command: ["/usr/bin/timeout", "10", "perl", "-Mbignum=bpi", "-wle", "print bpi(4000)"]
          restartPolicy: Never

    (Manifest adopted from

    You can play with the numbers and see it timeout or not. Typically computing 4000 digits of pi takes ~23 seconds on my workstation, so if you set it to 5 seconds it’ll probably always fail and if you set it to 120 seconds it will always work.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.