<p>I want to run a kubernetes Job exactly once. This may by a script that will do some database updates. We dont want for any reason, that script to be executed more than once.</p>

<p>Any suggestion, how can we do it with kubernetes.</p>

nimit garg
<p>You need to use a Job resource, with the <code>backoffLimit</code> set to 0, like the following:</p>

<pre><code>apiVersion: batch/v1
kind: Job
metadata:
  name: example
spec:
  backoffLimit: 0
  template:
    spec:
      containers:
        - name: example
          image: alpine:3
          command: ["sh", "-c", "exit 1"]
      restartPolicy: Never
</code></pre>

<p>Afthe the job has run once, if it fails, it will reach the backoffLimit, and will not retry. If you describe the job, you can verify it:</p>

<pre><code>Warning  BackoffLimitExceeded  117s  job-controller  Job has reached the specified backoff limit
</code></pre>
