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

datasource kubernetes_service should also allow selection by labels

Open mathze opened this issue 7 months ago • 0 comments

Terraform Version, Provider Version and Kubernetes Version

Terraform version: 1.11.3
Kubernetes provider version: 2.36.0
Kubernetes version: 1.32.2

Affected Resource(s)

  • kubernetes_service

Terraform Configuration Files

data "kubernetes_service" "this" {
  metadata {
    labels = {
      "release" = helm_release.this.name
    }
    namespace = var.namespace
  }
}

Debug Output

n.a.

Panic Output

n.a.

Steps to Reproduce

  1. terraform plan

Expected Behavior

terraform plan should not error.

Actual Behavior

As stated in #854, terraform plan complains about the name field to be mandatory

Error: resource name may not be empty

Important Factoids

I would expect the data source to behave like kubectl get service therefor it should be possible to retrieve resources just by their labels. E.g. kubectl get service -l mylabel=myvalue

References

  • GH-854

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

mathze avatar Apr 13 '25 07:04 mathze