<p>I would like to update the version on the label for a kubernetes deployment dynamically based on the version of the underlying docker image. For instance, In this example:</p>
<pre><code>...

  labels:
    app: appName
    version: 1.0.0 &lt;----- what I want to get updated
spec:
  containers:
    - image: dockerRepository/imageName:latest
      imagePullPolicy: Always
      name: appName
...
</code></pre>
<p>I would like to get the version label updated with the version that the docker image has. Not &quot;latest&quot; but the underlying version that latest points to.</p>
<p>Is this possible to be done dynamically or it has to be a manual process?</p>

LeYAUable
<p>You can use Helm charts for this purpose. you need to create <a href="https://docs.bitnami.com/tutorials/create-your-first-helm-chart/" rel="nofollow noreferrer">custom</a> chart for your deployment.
In which for label and Image you can use values as :</p>
<pre><code>metadata:
  labels:
     version: {{ .Values.tag}}
</code></pre>
<p>For Image as this:</p>
<pre><code>spec:
  containers:
    - image: dockerRepository/imageTag:{{ .Values.tag }}
</code></pre>
<p>Then in Values.yml, you need to provide values like:</p>
<pre><code>tag: &lt;your value&gt;
</code></pre>
<p>Everytime you need to update the tag with Image version, you can simple update the tag in values.yml and run:</p>
<pre><code>helm upgrade --set tag=&lt;your value&gt; &lt;name of your deployment&gt; ./&lt;name of your chart&gt;
</code></pre>
<p>You can also use <code>_helpers.tpl</code> for complex operations.</p>
