hashicorp / terraform-provider-kubernetes

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

Add `template_labels` support to `kubernetes_labels` #2310

Open korjek opened 1 year ago

korjek commented 1 year ago

Description

kubernetes_labels resource doesn't allow to set labels for a template (for example, when there in an intention to set labels for pods managed by deployment or statefulset).

Potential Terraform Configuration

resource "kubernetes_labels" "coredns" {
  api_version = "apps/v1"
  kind        = "Deployment"
  metadata {
    name = "coredns"
    namespace = "kube-system"
  }
  # These labels will be applied to the Pods created by the Deployment
  template_labels = {
    "my_label" = "my_value"
  }

  force = true
}
jrhouston commented 1 year ago

Thanks for opening this @korjek. This request makes sense, and we already do this in the kubernetes_annotations resource. The code for these resources are functionally almost identical so it would be easy just to take the code that does this for annotations and do it for labels.

theloneexplorerquest commented 8 months ago

I would like to work on this 😄