<p>In this stackoverflow question:  <a href="https://stackoverflow.com/questions/38261107/kubernetes-deployment-how-to-change-container-envi">kubernetes Deployment. how to change container environment variables for rolling updates?</a></p>

<p>The asker mentions mentions he edited the deployment to change the version to v2.  What's the workflow for automated deployments of a new version assuming the container v2 already exists?  How do you then deploy it without manually editing the deployment config or checking in a new version of the yaml?  </p>

<p>If you change the underlying container (like v1 -> another version also named v1) will Kubernetes deploy the new or the old?</p>

<p>Assuming <code>v1</code> is already running and you try to deploy <code>v1</code> again with the same environment variable values etc., then k8s will not see any difference between your current and updated deployment resource. 
Without diff, the k8s scheduler assumes that the desired state is already reached and won't schedule any new pods, even when <code>imagePullPolicy: Always</code> is set. The reason is that <code>imagePullPolicy</code> only has an effect on newly created pods. So if a new pod is being scheduled, then k8s will always pull the image again. Still, without any diff in your deployment, no new pod will be scheduled in the first place ..</p>

<p>For my deployments I always set a dummy environment variable, like a deploy timestamp <code>DEPLOY_TS</code>, e.g.:</p>

<pre><code>  containers:
  - name: my-app
    image: my-app:{{ .Values.app.version }}  ## value dynamically set by my deployment pipeline
    env:
    - name: DEPLOY_TS
      value: "{{ .Values.deploy_ts }}"  ## value dynamically set by my deployment pipeline
</code></pre>

<p>The value of <code>DEPLOY_TS</code> is always set to the current timestamp - so it is always a different value. That way k8s will see a diff on every deploy and schedule a new pod - even if the same version is being re-deployed. </p>

<p>(I am currently running k8s 1.7)</p>
