<p>I'm trying to share JSON patches between overlays. I could do something like:</p>

<pre><code>bases:
- ../bases
patchesJson6902:
- target:
  ...
</code></pre>

<p>But I'd have to copy the full target for each overlay. I'd prefer to describe the target and patch in one place, then pull that into the overlays that need it.</p>

<p>I therefore tried using <a href="https://github.com/ioandr/kustomize-example/tree/master/diamond-with-patches-transformers" rel="nofollow noreferrer">this approach</a> where your <code>kustomization.yaml</code> has a <a href="https://github.com/ioandr/kustomize-example/blob/master/diamond-with-patches-transformers/overlays/overlay1/kustomization.yaml#L4" rel="nofollow noreferrer"><code>transformers</code> directive</a>, pointing at a file <a href="https://github.com/kubernetes-sigs/kustomize/blob/9a954d4f0b84c997ffcf13b926aa2389146ed2bc/docs/plugins/builtins.md#example-5" rel="nofollow noreferrer">explicitly triggering the plugin</a>.</p>

<p>From <a href="https://github.com/kubernetes-sigs/kustomize/blob/9a954d4f0b84c997ffcf13b926aa2389146ed2bc/docs/plugins/builtins.md#builtin-plugins" rel="nofollow noreferrer">the docs</a> it looks like this should work in my overlay's <code>kustomization.yaml</code>:</p>

<pre><code>bases:
- ../bases

transformers:
- ../transformers/example
</code></pre>

<p>but when I run <code>kubectl apply -k</code> I get:</p>

<pre><code>Error: json: unknown field "transformers"
</code></pre>

<p>Can anyone point me at what I'm doing wrong? Is there a better way to do this?</p>

<p>You need to <a href="https://github.com/kubernetes-sigs/kustomize/blob/master/docs/INSTALL.md" rel="nofollow noreferrer">install</a> the <code>kustomize</code> binary rather than using <code>kubectl</code> to generate these manifests. As @coderanger mentioned, the version of Kustomize that is bundled with <code>kubectl</code> is from a release that predated Transformers.</p>

<p>After you have installed <code>kustomize</code>, you can then build your manifests like so:</p>

<p><code>kustomize build &gt;dir&lt;</code></p>

<p>Then will produce a stream of STDOUT similar to <code>kubectl kustomize &gt;dir&lt;</code></p>

<p>If you wish to directly apply the resultant manifests to your API server instead, you can pipe STDOUT directly into <code>kubectl apply</code>. For example:</p>

<p><code>kustomize build &gt;dir&lt; | kubectl apply -f-</code></p>
