<p>In our project, which also uses Kustomize, our base <code>deployment.yaml</code> file looks like this:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:IMAGE_TAG # &lt;------------------------------
        ports:
        - containerPort: 80
</code></pre>
<p>Then we use <code>sed</code> to replace <code>IMAGE_TAG</code> with the version of the image we want to deploy.</p>
<p>Is there a more sophisticated way to do this, rather than editing the text yaml file using <code>sed</code>?</p>

Behrang Saeedzadeh
<p>There is a specific transformer for this called the <a href="https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/images/" rel="noreferrer">images transformer</a>.
You can keep your deployment as it is, with or without tag:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80
</code></pre>
<p>and then in your kustomization file:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
  - deployment.yaml

images:
  - name: nginx
    newTag: MYNEWTAG
</code></pre>
<p>Do keep in mind that this will replace the tag of all the nginx images of all the resources included in your kustomization file. If you need to run multiple versions of nginx you can replace the image name in your deployment by a placeholder and have different entries in the transformer.</p>
