<p>The README for kustomize says that</p>

<blockquote>
  <p>It's like make, in that what it does is declared in a file, and it's like sed, in that it emits edited text.</p>
</blockquote>

<p>Does this analogy extend beyond the fact that files are used to declare what is needed?</p>

<p>Or, is kustomize backward chaining like make in that it reads all command input before working out what it has to do rather than work sequentially and step through the command input like bash working through a shell script?</p>

<p><strong>EDIT:</strong> Jeff Regan, of the Kustomize team in Google, explains the model for the way kustomize works towards the beginning of his talk <a href="https://youtu.be/ahMIBxufNR0" rel="nofollow noreferrer">Kustomize: Kubernetes Configuration Customization</a>. He also shows how kustomize may be daisy chained so the output of one kustomize may serve as the input to another kustomize. It seems that, as pointed out by ITChap below, kustomize starts by gathering all the resources referenced in the kustomization.yml file in the base dir. It the executes sequentially in a series of steps to perform the required substitutions and transformations interatively. Repeating the substitution/tranformation step as often as needed to complete. It then spits out the generated YAML on stdout. So I would say that it is not backward chaining like make but rather somewhere in between. HTH.</p>

<p>What I noticed so far is that kustomize will first accumulate the content of all the base resources then apply the transformations from your <code>kustomization.yml</code> files. If you have multiple level of overlays, it doesn't seem to pass the result from one level to the next.</p>

<p>Let's consider the following:</p>

<p><code>./base/pod.yml</code>:</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: test
spec:
  containers:
  - name: test
    image: busybox
</code></pre>

<p><code>./base/kustomization.yml</code>:</p>

<pre><code>apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - ../pod.yml
</code></pre>

<p><code>./overlays/l1/kustomization.yml</code>:</p>

<pre><code>apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
bases:
  - ../base
nameSuffix: "-l1"
</code></pre>

<p><code>./overlays/l2/kustomization.yml</code>:</p>

<pre><code>apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
bases:
  - ../l1
nameSuffix: "-l2"
</code></pre>

<p>When running <code>kustomize build overlays/l2</code> you are going to get a pod named <code>test-l1-l2</code> as expected.</p>

<p>But if you try to patch the base pod you would have to reference the pod using:</p>

<pre><code>patchesJson6902:
- target:
    version: v1
    kind: Pod
    name: test
  path: patch.yml
</code></pre>

<p>in your <code>./overlays/l1/kustomization.yml</code> <strong>but also</strong> in <code>./overlays/l2/kustomization.yml</code>. At the time the patch of l2 is applied, the referenced resource is still <code>test</code> and not <code>test-l1</code>.</p>

<p>I don't know kustomize well enough to understand the intention behind this but these are my observations. Hope it answers your question.</p>

<p>PS: this might change with <a href="https://github.com/kubernetes-sigs/kustomize/issues/1036" rel="nofollow noreferrer">https://github.com/kubernetes-sigs/kustomize/issues/1036</a></p>
