terraform-provider-kubernetes
terraform-provider-kubernetes copied to clipboard
kuberenetes_manifest doesn't recongnize out of band changes
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
- Define
kubernetes_manifest
terraform resource that points to a yaml file which contains a k8s manifest - terraform plan and apply
-
kubectl edit $resource_created_in_1 => add a label
foo: bar` - 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?
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 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 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.
Related https://github.com/hashicorp/terraform-provider-kubernetes/issues/1568
The issue extends beyond annotations.
This actually a pretty big issue which makes the use of this provider questionable. Please address this issue!