title: What is the recommended architecture for scheduled jobs in Kubernetes cluster?
body: <p>What is the recommended architecture for scheduled jobs in Kuberntes cluster?</p>
  
  <p>Consider following situation:
  You have some kind of job which you wish to run every ~ 24 hours and it takes around 2 hours to complete. Let it be for example a parser scraping info from some websites.</p>
  
  <p>You want it to run in your Kuberntes cluster so you enclose it in Docker image.</p>
  
  <p>The docker convention propose looking at container as at executable so you use your parser script as the default command in your Dockerfile:</p>
  
  <pre><code>CMD nodejs /src/parser.js
  </code></pre>
  
  <p>But now in Kuberntes when the parser finishes the container dies with it and will be restarted immediately.</p>
  
  <p>Coming around this you can specify some other bash script as the <code>CMD</code>. This script will run indefinitely and will run your parser script every 24 hours. However this means you've lost this nice property fo your image and can't just do</p>
  
  <pre><code>docker run my-parser-image
  </code></pre>
  
  <hr>
  
  <p>So is there a way in Kuberntes to run some container every xx hours and if it fails to run it again?
  More broadly what is the proposed way of running scheduled containerized jobs in  Kuberntes cluster?</p>