<p>I have 6 replicas of a pod running which I would like to restart\recreate every 5 minutes.</p>

<p>This needs to be a rolling update - so that all are not terminated at once and there is no downtime. How do I achieve this?</p>

<p>I tried using cron job, but seems not to be working : </p>

<pre><code>apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: scheduled-pods-recreate
spec:
  schedule: "*/5 * * * *"
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: ja-engine
            image: app-image
            imagePullPolicy: IfNotPresent
          restartPolicy: OnFailure
</code></pre>

<p>Although the job was created successfully and scheduled as per description below, it seems to have never run:</p>

<pre><code>Name:                       scheduled-pods-recreate
Namespace:                  jk-test
Labels:                     &lt;none&gt;
Annotations:                &lt;none&gt;
Schedule:                   */5 * * * *
Concurrency Policy:         Forbid
Suspend:                    False
Starting Deadline Seconds:  &lt;unset&gt;
Selector:                   &lt;unset&gt;
Parallelism:                &lt;unset&gt;
Completions:                &lt;unset&gt;
Pod Template:
  Labels:  &lt;none&gt;
  Containers:
   ja-engine:
    Image:           image_url
    Port:            &lt;none&gt;
    Host Port:       &lt;none&gt;
    Environment:     &lt;none&gt;
    Mounts:          &lt;none&gt;
  Volumes:           &lt;none&gt;
Last Schedule Time:  Tue, 19 Feb 2019 10:10:00 +0100
Active Jobs:         scheduled-pods-recreate-1550567400
Events:
  Type    Reason            Age   From                Message
  ----    ------            ----  ----                -------
  Normal  SuccessfulCreate  23m   cronjob-controller  Created job scheduled-pods-recreate-1550567400
</code></pre>

<p>So first thing, how do I ensure that it is running so the pods are recreated?</p>

<p>Also how can I ensure no downtime?</p>

<p>The updated version of the cronjob:</p>

<pre><code>apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: hello
spec:
  schedule: "*/1 * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: hello
            image: busybox
            args:
            - /bin/sh
            - -c
            - kubectl patch deployment runners -p '{"spec":{"template":{"spec":{"containers":[{"name":"jp-runner","env":[{"name":"START_TIME","value":"'$(date +%s)'"}]}]}}}}' -n jp-test
          restartPolicy: OnFailure
</code></pre>

<p>The pods are not starting with the message Back-off restarting failed container and error as given below:</p>

<pre><code>State:          Terminated
      Reason:       Error
      Exit Code:    127
</code></pre>

Chillax
<p>Starting with Kubernetes 1.15, you use the following command to perform rolling restart.</p>

<pre><code>kubectl rollout restart deployment &lt;deployment name&gt;
</code></pre>
