terraform-provider-kubernetes icon indicating copy to clipboard operation
terraform-provider-kubernetes copied to clipboard

kuberenetes_manifest doesn't recongnize out of band changes

Open shysank opened this issue 1 year ago • 4 comments

Terraform Version, Provider Version and Kubernetes Version

Terraform version: 1.4.6
Kubernetes provider version: 2.23.0
Kubernetes version: 1.24

Steps to Reproduce

  1. Define kubernetes_manifest terraform resource that points to a yaml file which contains a k8s manifest
  2. terraform plan and apply
  3. kubectl edit $resource_created_in_1 => add a label foo: bar`
  4. terraform plan

Expected Behavior

What should have happened? Plan should show that label foo" bar should be removed

Actual Behavior

Plan showed no changes

Is this the expected behavior?

shysank avatar Sep 01 '23 00:09 shysank

I guess it's because computed fields defaults to metadata.labels, metadata.annotations. Is there a way to mark a specific label as computed field? eg. computed_fields: [metadata.labels["resourceVersion"]]

shysank avatar Sep 01 '23 05:09 shysank

@shysank The computed_fields attribute can only address fields that are defined by the Kubernetes OpenAPI schema and metadata.labels is a map type in the Kubernetes schema. However, individual map elements are arbitrary and not part of the schema therefore they cannot be used in computed fields.

You can try to remove metadata.labels from the list of computed fields by explicitly setting a value for computed_fields, for example:

  computed_fields = ["metadata.annotations"]

Let us know if that helps.

alexsomesan avatar Sep 05 '23 20:09 alexsomesan

@alexsomesan Yes, thats what I'm doing right now. The problem is, since annotations are completely ignored in plan, we are missing some changes that we'd like to see. That was the motivation for my original question to have targeted keys as computed fields.

shysank avatar Sep 11 '23 19:09 shysank

Related https://github.com/hashicorp/terraform-provider-kubernetes/issues/1568

The issue extends beyond annotations.

n1ngu avatar May 03 '24 11:05 n1ngu

This actually a pretty big issue which makes the use of this provider questionable. Please address this issue!

NelsonIg avatar Feb 12 '25 11:02 NelsonIg