banzaicloud/terraform-provider-k8s

Deployment of resource whose kind was created by a CRD

RenaudDemarneffe opened this issue · 1 comments

Describe the bug
The K8S provider refuse to deploy resources whose type was created by a CRD deployed just before.
It's like if the K8S provider does not see that a new CRD exists into the cluster.

The error is:

no matches for kind "Elasticsearch" in version "elasticsearch.k8s.elastic.co/v1"

By manually checking the CRD into the cluster, the CRD are correctly created.

With the debug mode, I see that the K8S provider download the API from the cluster when it's loaded. The API contains the CRD known by the cluster. Those data are cached by the provider (k8s client-go).
The cache is not refreshed when the new CRD is created or a resource of kind created by CRD is deployed.
So, I presume that, when the provider create the resource of kind created by CRD, the provider (k8s client-go) checks if the kind is into the cache and does not find it.
I think that we need to invalide the cache after a resource creation or when the creation of a resource is refused because its kind is not into the cache.

Steps to reproduce the issue:
Deploy a CRD then create a resource of kind created by CRD.

Expected behavior
The resource is created.

Additional context
Version v0.7.3
Terraform v0.12.21

pepov commented

I'm going to look into this