<p>how to set image name/tag for container images specified in CRDs through the <code>kustomization.yaml</code> using the images field?</p>
<p>The <a href="https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/images/" rel="nofollow noreferrer">images</a> field works well when the container images are specified in either <code>Deployment</code> or <code>StatefulSet</code>, but not transform a CRD resource from:</p>
<pre><code>apiVersion: foo.example.com/v1alpha1
kind: Application
spec:
  image: xxx
</code></pre>
<p>To:</p>
<pre><code>apiVersion: foo.example.com/v1alpha1
kind: Application
spec:
  image: new-image:tag
</code></pre>

<p>Your task can be solved easily using <code>yq</code>. The command depends on the <code>yq</code> implementation you are using:</p>
<h3><a href="https://mikefarah.gitbook.io/yq/" rel="nofollow noreferrer">mikefarah/yq - version 4</a></h3>
<p><code>IMAGE=&quot;new-image:tag&quot; yq e '.spec.image = strenv(IMAGE)'</code></p>
<h3><a href="https://github.com/kislyuk/yq" rel="nofollow noreferrer">kislyuk/yq</a></h3>
<p><code>yq -y --arg IMAGE &quot;new-image:tag&quot; '.spec.image |= $IMAGE'</code></p>
