<p>First I have created two different version of image as below</p>

<blockquote>
  <p>docker image ls</p>
</blockquote>

<pre><code>REPOSITORY     |    TAG      |    IMAGE ID
isaac88/posts  |    0.0.1    |    xxx
isaac88/posts  |    0.0.5    |    yyy
</code></pre>

<p>Then I created a kubernetes deployment file as below</p>

<blockquote>
  <p>posts-depl.yaml</p>
</blockquote>

<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: posts-depl
spec:
  replicas: 1
  selector:
    matchLabels:
      app: posts
  template:
    metadata:
      labels:
        app: posts
    spec:
      containers:
        - name: posts
          image: isaac88/posts:0.0.1
</code></pre>

<p>If you noticed, I specified version of image in deployment yaml file. by swapping the version between <code>0.0.1</code> and <code>0.0.5</code> and executed below commands to see the differences</p>

<ol>
<li><code>kubectl apply -f posts-depl.yaml</code></li>
<li><code>kubectl get pods</code></li>
<li><code>kubectl logs xxxxxxxxx</code></li>
</ol>

<p>Everything works fine so far.</p>

<p>Now I've tried to remove <code>0.0.1</code> from the deployment yaml, i'm wondering on how it behaves since I do not have a latest version being tagged to my docker image. I've verified using <code>docker image ls</code></p>

<p>Below is my latest <code>yaml</code></p>

<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: posts-depl
spec:
  replicas: 1
  selector:
    matchLabels:
      app: posts
  template:
    metadata:
      labels:
        app: posts
    spec:
      containers:
        - name: posts
          image: isaac88/posts
</code></pre>

<p>After removed the version, I've ran <code>kubectl apply -f posts-depl.yaml</code> and surprisingly it is able to create the deployment successfully, and I went ahead and executed <code>kubectl logs xxxxx</code> on latest pods created, I see the logs which are belongs to version <code>0.0.1</code>. I don't understand the reason behind</p>

<p>That is because your deployment failed to fetch image with the latest tag
and rolled back to the previous version of the deployment where you have specified tag 0.0.1</p>

<p>Rolling updates are the default strategy to update the running version of your app.</p>

<p>You can read more about it <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#rolling-back-a-deployment" rel="nofollow noreferrer">here</a></p>
