<p>How to deploy and run a container in Kubernetes, that should do his job and terminate?</p>

<p>I thought this is what <a href="https://docs.openshift.com/enterprise/3.2/admin_guide/limit_runonce_pod_duration.html" rel="nofollow noreferrer">Run-Once</a> is for, but it looks like <a href="https://github.com/kubernetes/kubernetes/issues/24725" rel="nofollow noreferrer">it's not supported to work</a>.</p>

<p>I have some jobs, packed in docker images, that should be run either once/on demand (data import), where the config change should trigger re-run, or periodically (like volume backup). My idea was to deploy a container with <code>restartPolicy: never</code> which would stop and scale up to null after accomplishing.</p>

<p>What alternatives do I have for this missing functionality?</p>

9ilsdx 9rvj 0lo
<p>You can use a job/cronjob. This example is from kubernetes docs:</p>

<pre><code>apiVersion: batch/v1
kind: Job
metadata:
  name: pi
spec:
  backoffLimit: 5
  activeDeadlineSeconds: 100
  template:
    spec:
      containers:
      - name: pi
        image: perl
        command: ["perl",  "-Mbignum=bpi", "-wle", "print bpi(2000)"]
      restartPolicy: Never
</code></pre>

<p>So, it will calculate "pi" and will terminate</p>
