<p>So in order to update the images running on a pod, I have to modify the deployment config (yaml file), and run something like <code>kubectl apply -f deploy.yaml</code>.</p>

<p>This means, if I'm not editing the yaml file manually I'll have to use some template / search and replace functionality. Which isn't really ideal.</p>

<p>Are there any better approaches?</p>

<p>It seems there is a <code>kubectl rolling-update</code> command, but I'm not sure if this works for 'deployments'. </p>

<p>For example running the following: <code>kubectl rolling-update wordpress --image=eu.gcr.io/abcxyz/wordpress:deploy-1502443760</code></p>

<p>Produces an error of:</p>

<pre><code>error: couldn't find a replication controller with source id == default/wordpress
</code></pre>

<p>I am using this for changing images in Deployments:</p>

<pre><code>kubectl set image deployment/nginx-deployment nginx=nginx:1.9.1
</code></pre>

<p>If you view the yaml files as source of truth then use a tag like <code>stable</code> in the yaml and only issue <code>kubectl set image</code> commands when the tag is moved (use the sha256 image id to actually trigger a rollout; the image names are matched like a string so updating from <code>:stable</code> to <code>:stable</code> is a noop even if the tag now points to a different image).</p>

<p>See <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#updating-a-deployment" rel="nofollow noreferrer">updating a deployment</a> for more details.</p>

<p>The above requires the deployment replica count to be set more then 1, which is explained here: <a href="https://stackoverflow.com/a/45649024/1663462">https://stackoverflow.com/a/45649024/1663462</a>.</p>
