<p>I am using <a href="https://kustomize.io/" rel="nofollow noreferrer">https://kustomize.io/</a> have below is my kustomization.yaml file,</p>
<p>I would like to pass <code>newTag</code> image version to labels on <code>deployment.yaml</code> when i use ArgoCD to apply this file. Does anyone have any idea without using shell script to sed the <code>newtag</code> to deployment.yaml file.</p>
<p>deployment.yaml</p>
<pre><code>apiVersion: &quot;apps/v1&quot;
kind: &quot;Deployment&quot;
metadata:
  name: &quot;hellowolrd&quot;
spec:
  template:
    metadata:
      labels:
        app: aggregate
        appversion: ${newtag} &lt;&lt;&lt;&lt;&lt;
</code></pre>
<p>kustomization.yaml</p>
<pre><code>apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: hellowolrd
  newName: hellowolrd
  newTag: 12345
</code></pre>

<p>You can't do this directly with <code>newTag</code> value. However you can use a PatchTransformer built-in plugin to change <code>appversion</code> value.</p>
<p>Add this</p>
<pre class="lang-yaml prettyprint-override"><code>resources:
  - deployment.yaml
patches:
  - patch: |-
      - op: replace
        path: /spec/template/metadata/labels/appversion
        value: v2
    target:
      kind: Deployment
</code></pre>
<p>to your <em>kustomization.yaml</em>, and run <code>kustomize build</code>.<br />
The result will look like this</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: hellowolrd
spec:
  template:
    metadata:
      labels:
        app: aggregate
        appversion: v2
</code></pre>
<p>Yo ucan read more <a href="https://kubectl.docs.kubernetes.io/guides/extending_kustomize/builtins/#_patchtransformer_" rel="nofollow noreferrer">here</a>.</p>
