Body: <p>So I have the following <code>kustomize.yaml</code> file for my staging environment overlay and when I want to promote to production, I would like to move just the portion that has the image numbers into the production overlay. Ideally I would split out the images into a separate file called <code>versions.yaml</code>. I am not sure the best way to go about that. The container tag numbers are updated by the CI pipeline when a new container is created and pushed to the container repo.</p>
  <pre class="lang-yaml prettyprint-override"><code>apiVersion: kustomize.config.k8s.io/v1beta1
  kind: Kustomization
  namespace: staging
  namePrefix: stage-
  commonLabels:
    app: xxx-staging
  bases:
    - ./namespace.yaml
    - ./ingress.yaml
    - ../../../bases/container1
    - ../../../bases/container2
    - ../../../bases/container3
    - ../../../bases/container4
    - ../../../bases/container5
    - ../../../bases/container6
    - ../../../bases/container7
    - ../../../bases/container8
    - ../../../bases/container9
    - ../../../bases/container10
  images:
    - name: xxx.dkr.ecr.eu-central-1.amazonaws.com/container1
      newTag: &quot;1111&quot;
    - name: xxx.dkr.ecr.eu-central-1.amazonaws.com/container2
      newTag: &quot;1111&quot;
    - name: xxx.dkr.ecr.eu-central-1.amazonaws.com/container3
      newTag: &quot;1111&quot;
    - name: xxx.dkr.ecr.eu-central-1.amazonaws.com/container4
      newTag: &quot;1111&quot;
    - name: xxx.dkr.ecr.eu-central-1.amazonaws.com/container5
      newTag: &quot;1111&quot;
    - name: xxx.dkr.ecr.eu-central-1.amazonaws.com/container6
      newTag: &quot;1111&quot;
    - name: xxx.dkr.ecr.eu-central-1.amazonaws.com/container7
      newTag: &quot;1111&quot;
    - name: xxx.dkr.ecr.eu-central-1.amazonaws.com/container8
      newTag: &quot;1111&quot;
    - name: xxx.dkr.ecr.eu-central-1.amazonaws.com/container9
      newTag: &quot;1111&quot;
    - name: xxx.dkr.ecr.eu-central-1.amazonaws.com/container10
      newTag: &quot;1689&quot;
  </code></pre>
  
Comments: CC BY-SA 4.0
Comments: 2022-08-31T13:09:00.643Z
Comments: Note that you're using deprecated syntax here (`bases` has been deprecated in favor of `resources` since at least 2020).
Comments: larsks
Comments: CC BY-SA 4.0
Comments: 2022-08-31T13:09:34.763Z
Comments: I'm not sure I understand your question, but you could create a `kustomization.yaml` in your `production` overlay that (a) includes the `staging` overlay and then (b) has its own `images` section.
Comments: larsks
Comments: CC BY-SA 4.0
Comments: 2022-09-01T10:04:07.720Z
Comments: Thanks, I hadn't realised about the syntax I will fix that. I think I have it solved now, I have created an env directory with a kustomize file for the top part of the ```kustomization.yaml``` and included that as a resource in the kustomize file above so its just that resource and the images, that way I can copy that one file to the production directory when I am ready to promote.
Comments: Paul Bradbury
Tags: <kubernetes><release-management><kustomize>
Title: How to split out image tags from a kustomize file in for deployment
UserDisplayName: Paul Bradbury
ThreadText: # How to split out image tags from a kustomize file in for deployment
  
  (Asked by: username_0 on 2022-08-31)
  
  So I have the following `kustomize.yaml` file for my staging environment overlay and when I want to promote to production, I would like to move just the portion that has the image numbers into the production overlay. Ideally I would split out the images into a separate file called `versions.yaml`. I am not sure the best way to go about that. The container tag numbers are updated by the CI pipeline when a new container is created and pushed to the container repo.
  
  ```yaml
  apiVersion: kustomize.config.k8s.io/v1beta1
  kind: Kustomization
  namespace: staging
  namePrefix: stage-
  commonLabels:
    app: xxx-staging
  bases:
    - ./namespace.yaml
    - ./ingress.yaml
    - ../../../bases/container1
    - ../../../bases/container2
    - ../../../bases/container3
    - ../../../bases/container4
    - ../../../bases/container5
    - ../../../bases/container6
    - ../../../bases/container7
    - ../../../bases/container8
    - ../../../bases/container9
    - ../../../bases/container10
  images:
    - name: xxx.dkr.ecr.eu-central-1.amazonaws.com/container1
      newTag: "1111"
    - name: xxx.dkr.ecr.eu-central-1.amazonaws.com/container2
      newTag: "1111"
    - name: xxx.dkr.ecr.eu-central-1.amazonaws.com/container3
      newTag: "1111"
    - name: xxx.dkr.ecr.eu-central-1.amazonaws.com/container4
      newTag: "1111"
    - name: xxx.dkr.ecr.eu-central-1.amazonaws.com/container5
      newTag: "1111"
    - name: xxx.dkr.ecr.eu-central-1.amazonaws.com/container6
      newTag: "1111"
    - name: xxx.dkr.ecr.eu-central-1.amazonaws.com/container7
      newTag: "1111"
    - name: xxx.dkr.ecr.eu-central-1.amazonaws.com/container8
      newTag: "1111"
    - name: xxx.dkr.ecr.eu-central-1.amazonaws.com/container9
      newTag: "1111"
    - name: xxx.dkr.ecr.eu-central-1.amazonaws.com/container10
      newTag: "1689"
  
  ```
  
  **Tags:** kubernetes, release-management, kustomize
  
  > **Comments:**
  > **username_1**: Note that you're using deprecated syntax here (`bases` has been deprecated in favor of `resources` since at least 2020).  
  > **username_1**: I'm not sure I understand your question, but you could create a `kustomization.yaml` in your `production` overlay that (a) includes the `staging` overlay and then (b) has its own `images` section.  
  > **username_0**: Thanks, I hadn't realised about the syntax I will fix that. I think I have it solved now, I have created an env directory with a kustomize file for the top part of the ```kustomization.yaml``` and included that as a resource in the kustomize file above so its just that resource and the images, that way I can copy that one file to the production directory when I am ready to promote.  
  
  ---
  
  ## 0 answers
  
  