title: Kubernetes Engine - Pod deployment not updating to the latest image
body: <p>I’m following this tutorial for Google Cloud Platform: <a href="https://cloud.google.com/kubernetes-engine/docs/tutorials/hello-app" rel="nofollow noreferrer">https://cloud.google.com/kubernetes-engine/docs/tutorials/hello-app</a> . Basically I cloned the example <code>hello-app</code> project from Github both on Google Cloud (using Google cloud shell) and locally on my machine because I want to practise doing this tutorial, using both the cloud approach and my local machine (using Google Cloud SDK) - where I would then push the Docker image to the cloud, build and run it thereafter on Kubernetes.  </p>
  
  <p>1- My first, when I got to step 8, where I changed the source code string from “Hello, World” to “Hello, world! Version 2”, and string “Version: 1.0.0” to “Version: 2.0.0” in the Go file, basically the lines: </p>
  
  <pre><code>fmt.Fprintf(w, "Hello, world! Version 2\n")
  fmt.Fprintf(w, "Version: 2.0.0\n")
  </code></pre>
  
  <p>I realised that I changed the source code on my local machine (not the one on the cloud). I then went to the Google Cloud Shell in the Console, re-built a Docker image with <code>v2</code> tag, then pushed it to the Google Container Registry (not realising that I’m building an image from the unchanged code project stored on the cloud, rather than the one from my local machine). When I applied a rolling update to the existing deployment with an image update using <code>kubectl</code>, not surprisingly, it didn’t work. 
  So basically to fix this, I need to build an image from the (changed) source code project on my local machine and push that image to the Google Container Registry (using Google Cloud SDK shell). That’s the theory (I’m assuming at least from my understanding). I created an image with exactly the same tag (i.e. v2), bearing in mind there’s already a v2 image (with the unchanged code) stored in the Container Registry, done from my previous step. I wondered if it would simply overwrite the existing image in the Container Registry, which it did (looking the Container Registry > Images section, I can see a v2 image with Update showing just a few seconds ago). 
  Now everything is set for the final step, which is apply a rolling update to the existing deployment with an image update:</p>
  
  <pre><code>kubectl set image deployment/hello-web hello-web=gcr.io/${PROJECT_ID}/hello-app:v2
  </code></pre>
  
  <p>This was successful as I got the response:</p>
  
  <pre><code>deployment.extensions/hello-web image updated
  </code></pre>
  
  <p>However, when I navigated to Kubernetes Engine > Workloads, to view the deployed app on Kubernetes, although the status shows = <code>OK</code>, in the <code>Managed pods</code> section it shows the pods running from yesterday and the day before (in the <code>Created on</code> date column), not the deployment of today (June 29th):</p>
  
  <p><img src="https://i.imgur.com/940Bcpr.jpg" alt="Kubernetes - Managed Pods"></p>
  
  <p>1 (a) - which brings me to side question (still relating to the first question), The <code>Revision</code> column in the table above, does this mean the number of times I deployed new pods from an image? Because indeed I did try this step a few times, in a vain attempt to fix the issue (I think it might’ve been 4 times). 
  Going back to the main question, similarly if I try the external IP from the Load Balancer service, to load the site, it doesn’t show the changed code. Also, when I check the latest image pushed in the Container Registry, by navigating to Container Registry > Images, I can see a v2 of the image uploaded minutes ago. So the Container Registry does have the latest image I uploaded (meaning it overwritten the previous version 2 of the same image name in the Container Registry. Otherwise it should’ve failed if it couldn’t overwrite it). So I don’t quite understand, shouldn’t the last step (below) meant to deploy that last image v2 from the Container Registry?:</p>
  
  <pre><code>kubectl set image deployment/hello-web hello-web=gcr.io/${PROJECT_ID}/hello-app:v2
  </code></pre>
  
  <p>I’m not sure what I’m missing. </p>
  
  <p>2- As I’m new to Docker, I was wondering is there a way to pull the image from the Container Registry, and view the source code in the Image. Otherwise, how is it possible to verify which Image contains which version of the source code? This can cause much confusion, with many versions of images along with equally many versions of source code history changes. How can you tell which source code commit corresponds to which Docker image? </p>
  
  <p>3- Finally, can anyone advise on best practices of managing Kubernetes, in different scenarios. Say in the scenario where you deployed a container from an updated image version, but realised after there are issues or missing features, so you want to roll-back to the previous deployment. So is there best practises for managing such scenarios.</p>
  
  <p>Apologies for the long-winded text, and many thanks in advance. </p>