<p>I'm running GKE cluster and there is a deployment that uses image which I push to Container Registry on GCP, issue is - even though I build the image and push it with <code>latest</code> tag, the deployment keeps on creating new pods with the old one cached - is there a way to update it without re-deploying (aka without destroying it first)? </p>

<p>There is a known issue with the kubernetes that even if you change configmaps the old config remains and you can either redeploy or workaround with </p>

<pre><code>kubectl patch deployment $deployment -n $ns -p \
  "{\"spec\":{\"template\":{\"metadata\":{\"annotations\":{\"date\":\"`date +'%s'`\"}}}}}"
</code></pre>

<p>is there something similar with cached images? </p>

CptDolphin
<p>I think you're looking for kubectl set or patch which I found there in <a href="https://kubernetes.io/docs/reference/kubectl/cheatsheet/#updating-resources" rel="nofollow noreferrer">kubernetes documentation</a>.</p>

<p>To update image of deployment you can use <a href="https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#set" rel="nofollow noreferrer">kubectl set</a> </p>

<pre><code>kubectl set image deployment/name_of_deployment name_of_deployment=image:name_of_image
</code></pre>

<p>To update image of your pod you can use <a href="https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#patch" rel="nofollow noreferrer">kubectl patch</a> </p>

<pre><code>kubectl patch pod name_of_pod  -p '{"spec":{"containers":[{"name":"name_of_pod_from_yaml","image":"name_of_image"}]}}'
</code></pre>

<p>You can always use <a href="https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#edit" rel="nofollow noreferrer">kubectl edit</a> to edit which allows you to directly edit any API resource you can retrieve via the command line tool.</p>

<pre><code>kubectl edit deployment name_of_deployment
</code></pre>

<p>Let me know if you have any more questions.</p>
