Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validate_schema=false not working as expected #282

Open
alexkuklin opened this issue Jan 26, 2024 · 4 comments
Open

validate_schema=false not working as expected #282

alexkuklin opened this issue Jan 26, 2024 · 4 comments

Comments

@alexkuklin
Copy link

While trying to wrap kafka operatior installation into terraform, I've got

CustomResourceDefinition.apiextensions.k8s.io "kafkaclusters.kafka.banzaicloud.io" is invalid: metadata.annotations: Too long: must have at most 262144 bytes

tf code is

data "kubectl_path_documents" "crd" {
    pattern = "./manifests/*.yaml"
}

resource "kubectl_manifest" "kafka-operator-crds" {
    count     = length(data.kubectl_path_documents.crd.documents)
    yaml_body = element(data.kubectl_path_documents.crd.documents, count.index)

  validate_schema  = false
  wait_for_rollout = true
}

kubectl gives same error if used without --validate=false. With --validate=false it works fine.

@alekc
Copy link
Contributor

alekc commented Jan 26, 2024 via email

@alexkuklin
Copy link
Author

It helped, thank you.

Not very clear though.

@alekc
Copy link
Contributor

alekc commented Jan 26, 2024

It's the same issue as with Prometheus. Basically, when you run a normal apply, it will try to construct the whole yaml document and add an annotation "last_applied_config" (or something similar). In case of CRD, it can be an issue because it will exceed the maximum length.

If you are doing server side apply, it will only try to apply the fields within your yaml document ignoring everything else (and the diff will be calculated on the server side).

Something along those lines.

P.s. and just FIY since you have opened an issue on a pretty much dead project, once you switch to the kubernetes 1.27 and higher you are going to be hit with #270 I would strongly suggest to switch to my maintained fork ;) https://github.com/alekc/terraform-provider-kubectl/

terraform {
  required_providers {
    kubectl = {
      source = "alekc/kubectl"
      version = "2.0.4"
    }
  }
}

@alexkuklin
Copy link
Author

Oops.
I followed terraform registry link.
Thank you for heads up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants