title: Is there a way to have kustomize merge the content of a file into a yaml file?
body: <p>I am curious to know if there is a way to do a Kustomize replacement or other operation to inject the contents of a non-yaml file into a yaml file using Kustomize. I know Kustomize is not a template engine and that this could be accomplished with Helm, but using the tool I am already using, is this possible?</p>
  <p>My use case is to store OPA policies as native rego, which allows use of OPA unit tests, and to inject the content of these rego files into Gatekeeper constraints during Kustomize deployment. This will remove the requirement for custom pipeline processing or manual copy/paste to accomplish this.</p>
  <p>Example opaRule.rego file</p>
  <pre><code>package k8sdisallowedtags
  
  violation[{&quot;msg&quot;: msg}] {
      container := input_containers[_]
      tags := [forbid | tag = input.parameters.tags[_] ; forbid = endswith(container.image, concat(&quot;:&quot;, [&quot;&quot;, tag]))]
      any(tags)
      msg := sprintf(&quot;container &lt;%v&gt; uses a disallowed tag &lt;%v&gt;; disallowed tags are %v&quot;, [container.name, container.image, input.parameters.tags])
  }
  ...
  </code></pre>
  <p>Example constraintTemplate.yaml file</p>
  <pre><code>apiVersion: templates.gatekeeper.sh/v1beta1
  kind: ConstraintTemplate
  metadata:
    name: k8sdisallowedtags
    namespace: kube-system
    annotations:
      description: Requires container images to have an image tag different
        from the ones in a specified list.
  spec:
    crd:
      spec:
        names:
          kind: K8sDisallowedTags
        validation:
          openAPIV3Schema:
            properties:
              tags:
                type: array
                items:
                  type: string
    targets:
      - target: admission.k8s.gatekeeper.sh
        rego: |-
          {CONTENT OF OPA RULE POLICY HERE}
  </code></pre>