<p>I have a Pod - I want to update to latest version of container image, if it fails then want to revert it back to earlier version of container image.</p>
<p>Which approach of below will be good to update to latest or earlier container image.
1&gt; using kubectl patch is good option?
2&gt; deleting the pod and again creating the pod is good option?</p>
<p>what are benefits/disadvantages of both approach.</p>
<pre><code>kubectl patch pod test-pod -p '{&quot;spec&quot;:{&quot;containers&quot;:[{&quot;name&quot;:&quot;test&quot;,&quot;image&quot;:&quot;1.0&quot;}]}}'
</code></pre>
<p><code>kubectl delete pod test-pod and kubectl apply -f testpod.yaml</code></p>

Jayashree Madanala
<p>From the docs <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#use-case" rel="nofollow noreferrer">here</a> one of the use cases of deployment</p>
<blockquote>
<p>Rollback to an earlier Deployment revision if the current state of the
Deployment is not stable. Each rollback updates the revision of the
Deployment.</p>
</blockquote>
<p>So use deployment to perform <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#updating-a-deployment" rel="nofollow noreferrer">rolling update</a> and <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#rolling-back-a-deployment" rel="nofollow noreferrer">rollback</a> when necessary</p>
<pre><code>kubectl set image deployment.v1.apps/nginx-deployment nginx=nginx:1.161 --record=true
</code></pre>
<p>Check rollout history</p>
<pre><code>kubectl rollout history deployment.v1.apps/nginx-deployment
</code></pre>
<p>Rollback to a previous version</p>
<pre><code>kubectl rollout undo deployment.v1.apps/nginx-deployment
</code></pre>
