<p dir="auto">Repro Steps:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="kubectl create -f nginx-deployment.yaml 
deployment &quot;nginx-deployment&quot; created

kubectl get deployments
NAME               DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
nginx-deployment   3         3         3            3           0s

kubectl rollout history deployment/nginx-deployment
deployments &quot;nginx-deployment&quot;:
REVISION        CHANGE-CAUSE
1               &lt;none&gt;"><pre class="notranslate">kubectl create -f nginx-deployment.yaml 
deployment <span class="pl-s"><span class="pl-pds">"</span>nginx-deployment<span class="pl-pds">"</span></span> created

kubectl get deployments
NAME               DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
nginx-deployment   3         3         3            3           0s

kubectl rollout <span class="pl-c1">history</span> deployment/nginx-deployment
deployments <span class="pl-s"><span class="pl-pds">"</span>nginx-deployment<span class="pl-pds">"</span></span>:
REVISION        CHANGE-CAUSE
1               <span class="pl-k">&lt;</span>none<span class="pl-k">&gt;</span></pre></div>
<p dir="auto">Note: <code class="notranslate">CHANGE-CAUSE</code> has value <code class="notranslate">&lt;none&gt;</code>, since deployment file did not contain any annotations.</p>
<p dir="auto">Modify nginx-deployment.yaml file adding annotation <code class="notranslate">foo-bar</code> like so:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nginx-deployment
  annotations:
    kubernetes.io/change-cause: foo-bar
spec:
  replicas: 3
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        ports:
        - containerPort: 80"><pre class="notranslate"><span class="pl-ent">apiVersion</span>: <span class="pl-s">extensions/v1beta1</span>
<span class="pl-ent">kind</span>: <span class="pl-s">Deployment</span>
<span class="pl-ent">metadata</span>:
  <span class="pl-ent">name</span>: <span class="pl-s">nginx-deployment</span>
  <span class="pl-ent">annotations</span>:
    <span class="pl-ent">kubernetes.io/change-cause</span>: <span class="pl-s">foo-bar</span>
<span class="pl-ent">spec</span>:
  <span class="pl-ent">replicas</span>: <span class="pl-c1">3</span>
  <span class="pl-ent">template</span>:
    <span class="pl-ent">metadata</span>:
      <span class="pl-ent">labels</span>:
        <span class="pl-ent">app</span>: <span class="pl-s">nginx</span>
    <span class="pl-ent">spec</span>:
      <span class="pl-ent">containers</span>:
      - <span class="pl-ent">name</span>: <span class="pl-s">nginx</span>
        <span class="pl-ent">image</span>: <span class="pl-s">nginx:1.7.9</span>
        <span class="pl-ent">ports</span>:
        - <span class="pl-ent">containerPort</span>: <span class="pl-c1">80</span></pre></div>
<p dir="auto">Delete nginx-desployment and re-create one from scratch</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="kubectl delete deployment/nginx-deployment
deployment &quot;nginx-deployment&quot; deleted"><pre class="notranslate">kubectl delete deployment/nginx-deployment
deployment <span class="pl-s"><span class="pl-pds">"</span>nginx-deployment<span class="pl-pds">"</span></span> deleted</pre></div>
<p dir="auto">Assert deployment is gone:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content=" kubectl get deployments"><pre class="notranslate"> kubectl get deployments</pre></div>
<p dir="auto">Create new nginx-deployment:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="kubectl apply -f nginx-deployment.yaml 
deployment &quot;nginx-deployment&quot; created

kubectl rollout history deployment/nginx-deployment
deployments &quot;nginx-deployment&quot;:
REVISION        CHANGE-CAUSE
1               kubectl apply -f nginx-deployment.yaml"><pre class="notranslate">kubectl apply -f nginx-deployment.yaml 
deployment <span class="pl-s"><span class="pl-pds">"</span>nginx-deployment<span class="pl-pds">"</span></span> created

kubectl rollout <span class="pl-c1">history</span> deployment/nginx-deployment
deployments <span class="pl-s"><span class="pl-pds">"</span>nginx-deployment<span class="pl-pds">"</span></span>:
REVISION        CHANGE-CAUSE
1               kubectl apply -f nginx-deployment.yaml</pre></div>
<p dir="auto">Note: <code class="notranslate">CHANGE-CAUSE</code> reflect the actual command and not the value from the file</p>
<p dir="auto">Apply the same change again:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="kubectl apply -f nginx-deployment.yaml 
deployment &quot;nginx-deployment&quot; configured

kubectl rollout history deployment/nginx-deployment
deployments &quot;nginx-deployment&quot;:
REVISION        CHANGE-CAUSE
1               foo-bar"><pre class="notranslate">kubectl apply -f nginx-deployment.yaml 
deployment <span class="pl-s"><span class="pl-pds">"</span>nginx-deployment<span class="pl-pds">"</span></span> configured

kubectl rollout <span class="pl-c1">history</span> deployment/nginx-deployment
deployments <span class="pl-s"><span class="pl-pds">"</span>nginx-deployment<span class="pl-pds">"</span></span>:
REVISION        CHANGE-CAUSE
1               foo-bar</pre></div>
<p dir="auto">Note: second time around annotation is correctly updated. Since there were no other changes to the deployment, no new pods/replicasets were created.</p>
<p dir="auto">Repeat applying the same deployment file and observe alternating value in <code class="notranslate">CHANGE-CAUSE</code></p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="kubectl apply -f nginx-deployment.yaml 
deployment &quot;nginx-deployment&quot; configured

kubectl rollout history deployment/nginx-deployment
deployments &quot;nginx-deployment&quot;:
REVISION        CHANGE-CAUSE
1               kubectl apply -f nginx-deployment.yaml

kubectl apply -f nginx-deployment.yaml 
deployment &quot;nginx-deployment&quot; configured

kubectl rollout history deployment/nginx-deployment
deployments &quot;nginx-deployment&quot;:
REVISION        CHANGE-CAUSE
1               foo-bar"><pre class="notranslate">kubectl apply -f nginx-deployment.yaml 
deployment <span class="pl-s"><span class="pl-pds">"</span>nginx-deployment<span class="pl-pds">"</span></span> configured

kubectl rollout <span class="pl-c1">history</span> deployment/nginx-deployment
deployments <span class="pl-s"><span class="pl-pds">"</span>nginx-deployment<span class="pl-pds">"</span></span>:
REVISION        CHANGE-CAUSE
1               kubectl apply -f nginx-deployment.yaml

kubectl apply -f nginx-deployment.yaml 
deployment <span class="pl-s"><span class="pl-pds">"</span>nginx-deployment<span class="pl-pds">"</span></span> configured

kubectl rollout <span class="pl-c1">history</span> deployment/nginx-deployment
deployments <span class="pl-s"><span class="pl-pds">"</span>nginx-deployment<span class="pl-pds">"</span></span>:
REVISION        CHANGE-CAUSE
1               foo-bar</pre></div>
<h2 dir="auto">what</h2>
<ul dir="auto">
<li>Let the user override the default <code class="notranslate">change-cause</code> generated by <code class="notranslate">kubectl</code> by specifying it in the <code class="notranslate">metadata</code> of the resource file</li>
</ul>
<p dir="auto">Example:<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/52489/15233372/04024156-185d-11e6-8d1f-9f4131bd7829.png"><img src="https://cloud.githubusercontent.com/assets/52489/15233372/04024156-185d-11e6-8d1f-9f4131bd7829.png" alt="image" style="max-width: 100%;"></a></p>
<h2 dir="auto">why</h2>
<ul dir="auto">
<li>The automatic annotations are not very helpful if the same command is always executed</li>
<li>The end-user can provide more meaningful annotations in the context of their application (i.e. git commit messages, git hash, release version, etc)</li>
</ul>
<h2 dir="auto">note</h2>
<p dir="auto">Specifying <code class="notranslate">change-cause</code> sometimes works. Not sure if this is due to a race-condition.</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/52489/15233410/59bfb98e-185d-11e6-9989-0822b4c1d1a7.png"><img src="https://cloud.githubusercontent.com/assets/52489/15233410/59bfb98e-185d-11e6-9989-0822b4c1d1a7.png" alt="image" style="max-width: 100%;"></a></p>