terraform-provider-kubectl
terraform-provider-kubectl copied to clipboard
Unexpected EOF
Description
Since some weeks use this provider to solve CRD Updates for the kube-prometheus-stack. The most time it works well, but some times we run into following issue at the terraform plan/apply :
Error: Plugin error
with module.prometheus-operator.kubectl_manifest.crd_alertmanagers,
on .terraform/modules/prometheus-operator/crds.tf line 17, in resource "kubectl_manifest" "crd_alertmanagers":
17: resource "kubectl_manifest" "crd_alertmanagers" {
The plugin returned an unexpected error from
plugin.(*GRPCProvider).UpgradeResourceState: rpc error: code = Internal desc
= unexpected EOF
Unfortunately even with TF_LOG=DEBUG i dont get more information than this. The crds are relativley big with up to 5K Lines. Any idea what could lead to this issue?
Environment
Terraform v1.0.5 on darwin_amd64
- provider registry.terraform.io/gavinbunney/kubectl v1.13.1
Hey @steveizzle ,
could you maybe let us know how you are pushing this files via kubectl e.g provide all them at once and then use for_each or individual files?
One issue may be this: https://github.com/prometheus-community/helm-charts/blob/main/charts/kube-prometheus-stack/crds/crd-probes.yaml#L3 -- try to remove it (as that is needed when splitting manifest when you apply them all at once) and see if that will resolve the issue.
Best,
Hey i did that directly with individual files and without for_each like:
resource "kubectl_manifest" "crd_podmonitors" {
yaml_body = file("${local.crd_path}/podmonitors.yaml")
}
i use the crds from the prometheus-operator (https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.52.0/example/prometheus-operator-crd/monitoring.coreos.com_alertmanagerconfigs.yaml) and removed the "---", but that didnt solve the problem unfortunately
I am experiencing exactly the same issue, as mentioned in the issue this only happens sporadically and the error can occur on any of the CRDs. We are using a for each loop that reads the CRDs form a crd sub folder in the module. For reference line "---" has been removed from each CRD.
resource "kubectl_manifest" "crds" {
for_each = var.skip_crds ? {} : local.crd_files
yaml_body = file(each.value)
server_side_apply = true
wait = true
}
locals.tf
crd_files = { for x in fileset(path.module, "crds/*.yaml") : basename(x) => "${path.module}/${x}" }