hashicorp / terraform-provider-kubernetes

Terraform Kubernetes provider
https://www.terraform.io/docs/providers/kubernetes/
Mozilla Public License 2.0
1.58k stars 966 forks source link

`kubernetes_node_taints` causing overwrite when applying with `kubernetes_labels` #2247

Open BBBmau opened 1 year ago

BBBmau commented 1 year ago

Terraform Version, Provider Version and Kubernetes Version

Terraform version: v1.4.5
Kubernetes provider version: v2.23.0
Kubernetes version: v1.25.3

Affected Resource(s)

Terraform Configuration Files

resource "kubernetes_node_taint" "taint_workers_dcc" {
  metadata {
    name = "minikube"
  }
  taint {
    key    = "zone"
    value  = "onprem-dcc"
    effect = "NoSchedule"
  }
}

resource "kubernetes_labels" "nodes" {
  api_version = "v1"
  kind        = "Node"

  metadata {
    name = "minikube" 
  }

  labels = {
    test = "test"
  }

}

Steps to Reproduce

  1. terraform apply
  2. terraform apply

Expected Behavior

What should have happened?

Should apply resource successfully after first apply and not attempt to apply on the second apply

Actual Behavior

What actually happened?

on second apply it will apply the node taints despite already creating it in the first apply.

The third apply will result in the labels from kubernetes_labels to be missing leading it needing to be created once more

Important Factoids

References

Community Note

alfred-de-souza commented 4 weeks ago

Same response as in https://github.com/hashicorp/terraform-provider-kubernetes/issues/1791#issuecomment-2015652590, this was fixed with PR #1831.
The workaround is to set the field_manager for both kubernetes_node_taint and kubernetes_labels with 2 different values.