This repository has been archived by the owner on Aug 11, 2021. It is now read-only.
CRD dependency error when CR definition and CR instance in same TF project #247
Labels
bug
Something isn't working
Terraform, Provider, Kubernetes versions
Affected Resource(s)
kubernetes_manifest
(from kubernetes-alpha v0.5.0)Terraform Configuration Files
Error
Expected Behavior
The
kubernetes-alpha
provider should honor thedepends_on
clause. ie waiting for the CR definition to exist before checking on the state of the CR object instance.Actual Behavior
There are similar issues filed related to
Error: Failed to determine GroupVersionResource for manifest
. The issue I am filing here is minimal and generic, using a self-made CRD which doesn't depend on any helm chart or other resources. Also use latest version as of 2021-07-09.TERRAFORM CONFIG + YAML resources: kubernetes-alpha_CRD-dependency-error.zip
I guess the cause might be that
kubernetes-alpha
uses Server Side Apply (SSA). As stated in the blog Deploy Any Resource With The New Kubernetes Provider for HashiCorp TerraformBecause
kubernetes-alpha
attemps to query the Kubernetes API about the state of the CR instance, in my example, theTrillucination
doesn't exist yet on the server side, causingterraform plan
to fail. Unfortunately, that CR could not exist yet, because it is the job of the TF config to create it ftrst.When it comes to query Kunermetes API about Custom Resource, there is a dependency chain: CR definition must exist before CR object instance could be created. We solve that manually by sequencing the
kubectl apply -f ...
in 2 separate steps. Butterraform plan
tries to make the inventory of it's state in one go and find itself in a kind of "resource not found" situation.I think the
kubernetes-alpha
should handle this "CR dependency" chain by skipping the check on the dependant CR instances when the CR definition itself is created within the same TF config/project. And just consider the CR instance as not yet exists.Important Factoids
References
Error: Failed to determine GroupVersionResource for manifest
)Community Note
The text was updated successfully, but these errors were encountered: