<p>I'm using kustomize to pipe a manifest to kubectl on a new k8s cluster (v1.17.2). This includes CRDs, but other objects are unable to find them. For example:</p>

<pre><code>unable to recognize "STDIN": no matches for kind "Certificate" in version "cert-manager.io/v1alpha2"
unable to recognize "STDIN": no matches for kind "IngressRoute" in version "traefik.containo.us/v1alpha1"
</code></pre>

<p>The CRDs are defined in the <code>resources</code> section of my kubectl, they show in the output which I'm piping to kubectl, and I'm sure this approach of putting everything in one file worked last time I did it.</p>

<p>If I apply the CRDs first, then apply the main manifest separately, it all goes through without a problem. Can I do them all at the same time? If so, what am I doing wrong; if not, why did it work before?</p>

<p>Can anyone point me at where the problem may lie?</p>

<p>Sample CRD definition:</p>

<pre><code>apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  name: ingressroutetcps.traefik.containo.us
spec:
  group: traefik.containo.us
  names:
    kind: IngressRouteTCP
    plural: ingressroutetcps
    singular: ingressroutetcp
  scope: Namespaced
  version: v1alpha1
</code></pre>

Sausage O' Doom
<p>Kustomize does not, yet, have a way to control order of object creation. If you are piping straight into kubectl then you have to either separate the CRDs into their own app so that you apply CRDs, wait for them to finished and then apply the resources that depend on them. Or you run the apply twice.</p>
<p>When using kustomize with a GitOps tools they tend to have a custom way of setting resource ordering creation. Such as <a href="https://argo-cd.readthedocs.io/en/stable/user-guide/sync-waves/" rel="nofollow noreferrer">sync-waves for Argo-CD</a> or <a href="https://github.com/fluxcd/kustomize-controller#control-the-execution-order" rel="nofollow noreferrer">kustomization depends-on in Flux</a>.</p>
