GalleyBytes / terraform-operator

A Kubernetes CRD to handle terraform operations
http://tf.galleybytes.com
Apache License 2.0
366 stars 47 forks source link

Using `spec.keepLatestPodsOnly` removes the secrets created via `spec.outputsSecret` #107

Closed isaaguilar closed 2 years ago

isaaguilar commented 2 years ago

In the cleanup code to remove old resources that are not part of the current resource generation, the secret containing the terraform outputs, defined by spec.outputsSecret, is also getting removed.

https://github.com/isaaguilar/terraform-operator/blob/aec31a2e60a2cf754b74fec357ea345a73a90468/pkg/controllers/terraform_controller.go#L875-L880

Since the labels that are getting added to the secrets are used for ownership to make cleanup easy, it's deleting things that should persist. The code should recognize resources that should not be removed.