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

Detect drifts between the manifest and its live Kubernetes resources

Open chotiwat opened this issue 7 months ago • 3 comments

Description

This PR aims to address #1095 by performing a dry-run, server-side apply of the manifest during planning, which allows Terraform to detect any changes to the Kubernetes resources managed by the Helm release.

Mini Changelog

  • Introduce a new resources attribute which tracks Kubernetes resources managed by the deployed Helm release
    • The attribute is a map of resource key to resource JSON string.
    • Fields managed by kube-controller-manager or updated via subresource APIs (e.g. /status and /scale) are removed to avoid perpetual drifts.
    • Sensitive values are redacted like in the manifest attribute.
    • Fields like uid, creationTimestamp, resourceVersion, and managedFields are scrubbed to prevent the inconsistent final plan issue.
  • Generate a new version of resources during planning using a dry-run, server-side apply for diffing
  • Add acceptance tests to confirm that Kubernetes resources are reconciled when they are modified or deleted

Acceptance tests

  • [x] Have you added an acceptance test for the functionality being added?

Release Note

Release note for CHANGELOG:

`resource/helm_release`: add `resources` map attribute to allow drift detection against live kubernetes resources [GH-1095](https://github.com/hashicorp/terraform-provider-helm/issues/1095)

References

https://github.com/hashicorp/terraform-provider-helm/issues/1095 https://github.com/hashicorp/terraform-provider-helm/issues/1239

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

chotiwat avatar Jul 25 '24 01:07 chotiwat