<p>I do have deployment with single pod, with my custom docker image like:</p>

<pre><code>containers:
  - name: mycontainer
    image: myimage:latest
</code></pre>

<p>During development I want to push new latest version and make Deployment updated.
Can't find how to do that, without explicitly defining tag/version and increment it for each build, and do</p>

<pre><code>kubectl set image deployment/my-deployment mycontainer=myimage:1.9.1
</code></pre>

<p>You can configure your pod with a grace period (for example 30 seconds or more, depending on container startup time and image size) and set <code>"imagePullPolicy: "Always"</code>. And use <code>kubectl delete pod pod_name</code>.
A new container will be created and the latest image automatically downloaded, then the old container terminated.</p>

<p>Example:</p>

<pre><code>spec:
  terminationGracePeriodSeconds: 30
  containers:
  - name: my_container
    image: my_image:latest
    imagePullPolicy: "Always"
</code></pre>

<p>I'm currently using Jenkins for automated builds and image tagging and it looks something like this:</p>

<pre><code>kubectl --user="kube-user" --server="https://kubemaster.example.com"  --token=$ACCESS_TOKEN set image deployment/my-deployment mycontainer=myimage:"$BUILD_NUMBER-$SHORT_GIT_COMMIT"
</code></pre>

<p>Another trick is to intially run:</p>

<pre><code>kubectl set image deployment/my-deployment mycontainer=myimage:latest
</code></pre>

<p>and then:</p>

<pre><code>kubectl set image deployment/my-deployment mycontainer=myimage
</code></pre>

<p>It will actually be triggering the rolling-update but be sure you have also <code>imagePullPolicy: "Always"</code> set.</p>

<p><strong>Update:</strong></p>

<p>another trick I found, where you don't have to change the image name, is to change the value of a field that will trigger a rolling update, like <code>terminationGracePeriodSeconds</code>. You can do this using <code>kubectl edit deployment your_deployment</code> or <code>kubectl apply -f your_deployment.yaml</code> or using a patch like this:</p>

<pre><code>kubectl patch deployment your_deployment -p \
  '{"spec":{"template":{"spec":{"terminationGracePeriodSeconds":31}}}}'
</code></pre>

<p>Just make sure you always change the number value.</p>
