2

I am installing Custom Resources through an Operator. However, kubectl apply is blocked on
"Error from server (NotFound): customresourcedefinitions.apiextensions.k8s.io "my-crd.example.com" not found."

If there were a switch on kubectl apply along the lines of --no-typechecking, it would solve this. I would not cause a problem with a missing CRD, because the apply just sends the Kubernetes objects to etcd. Then, by the time that the Operator actually constructs the Custom Resource, the Custom Resource Definition would be available. (I have other code that guarantees that.)

So, can I suspend the typechecking that produces this error?

Joshua Fox
  • 18,704
  • 23
  • 87
  • 147

1 Answers1

4

No, you can’t use a CRD API without actually creating the CRD. It’s not a type check, it’s how the system works through and through.

coderanger
  • 52,400
  • 4
  • 52
  • 75
  • You are saying that etcd itself is typesafe? So, any workarounds for this? As is, there is a temporal dependency, which goes against the spirit of declarative creation of resources. – Joshua Fox Feb 04 '20 at 17:38
  • No, etcd is not involved, that is an error from kube-apiserver which manages the kubernetes api. – coderanger Feb 04 '20 at 17:44
  • 1
    As for temporal issues, it’s convergency, run it over and over until you have no errors :) tools like Kustomize and Helm also automatically sort input so crds are first, which usually helps. – coderanger Feb 04 '20 at 17:45
  • Can you point me to documentation on the typechecking done by the API Server. Clearly the metamodel is not compiled into the API server as CRDs extend the metamodel. – Joshua Fox Feb 04 '20 at 18:33
  • 1
    You keep saying "typechecking". That's not a type check error. There is some optional support for OpenAPI schema verification on objects however what you have there is simply an HTTP 404 response from a REST API. You tried to access an object that does not exist. – coderanger Feb 04 '20 at 18:59
  • I see. But in this case, the object that does not exist is the CRD, which is a meta-object, a type, right? – Joshua Fox Feb 04 '20 at 19:42
  • 1
    There is no "meta-object". CRDs are normal K8s API objects like any other :) – coderanger Feb 04 '20 at 19:44