Reputation: 103
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:
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"
The CRDs are defined in the resources
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.
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?
Can anyone point me at where the problem may lie?
Sample CRD definition:
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
Upvotes: 7
Views: 8057
Reputation: 1433
I solved this problem by using Skaffold
and deploying all my CRDs
with kubectl
:
deploy:
kubectl:
manifests:
- custom_resources.yaml
kustomize:
paths:
- kustomize_directory
Upvotes: 0
Reputation: 665
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.
When using kustomize with a GitOps tools they tend to have a custom way of setting resource ordering creation. Such as sync-waves for Argo-CD or kustomization depends-on in Flux.
Upvotes: 1
Reputation: 1
i met the same issue, i guess it is about that kubetcl
could not find the resource if trying to install the crd
on the cluster first, to verify this, could running the command kubectl api-resources
, new crd
will not in the list, but if you apply
the crd
first, then the crd
record will be there, then kustomize build . | kubectl apply -f -
can works fine. But i really do not know how to add the resource firstly.
Upvotes: 0
Reputation: 11
I came across your question when working on an issue with trying to bring up Traefik with Kustomize on Kubernetes... My issue was resolved by ensuring the namespace was accurate in my kustomization.yml file. In my case, I had to change it to match what was in the other yml files in my deployment. Not sure if you eventually figured it out but I figured I would respond in case that was it...
Upvotes: 1