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

ownerReferences is Unsupported argument

Open OmerKahani opened this issue 3 years ago • 4 comments

Terraform Version, Provider Version and Kubernetes Version

Terraform v1.2.5
Kubernetes provider version: v2.12.1
Kubernetes version: 1.21

Affected Resource(s)

  • kubernetes_secret
  • And all the others

Terraform Configuration Files

resource "kubernetes_secret" "secret" {
  metadata {
    name      = "name"
    namespace = "namespace"
    ownerReferences = {
      apiVersion = "api"
      kind = "kind"
      name = "name"
      uid = "uid"
    }
  }
  ...
}

Output

│ Error: Unsupported argument
│
│   on k8s-secrets.tf line 15, in resource "kubernetes_secret" "secret":
│   15:     ownerReferences = {
│
│ An argument named "ownerReferences" is not expected here.

Steps to Reproduce

  1. terraform plan

Expected Behavior

ownerReferences is part of the K8s metadata object and should be supported

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

OmerKahani avatar Aug 21 '22 08:08 OmerKahani

Hi @OmerKahani,

Could you please share some more information about the need to manage ownerReferences by terraform? Usually ownerReferences is set up by one of the controllers.

Thank you.

P.S.: I have updated your initial post and added the Community Note part.

arybolovlev avatar Aug 24 '22 08:08 arybolovlev

We are using it from a controller. We use https://github.com/hashicorp/terraform-k8s to run terraform inside the cluster. So we also want to add ownerReferences so we can track the resources that was created

OmerKahani avatar Aug 25 '22 12:08 OmerKahani

This sounds more like a task for labels or annotations, rather than owner reference. It would be helpful if you can share a more concrete example in case I am missing something here.

Thank you.

arybolovlev avatar Aug 31 '22 07:08 arybolovlev

The terraform K8s operator, also part of HashiCorp, is using a CRD in the cluster. That CRD is pointing to a TF module, in our case, that TF module will create more resources in the cluster.

We want those resources to be linked to the workspace, so other tools we use (like ArgoCD) will be able to show that they are managed by that workspace. ArgoCD understand ownerReferences by default

OmerKahani avatar Aug 31 '22 14:08 OmerKahani

Marking this issue as stale due to inactivity. If this issue receives no comments in the next 30 days it will automatically be closed. If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. This helps our maintainers find and focus on the active issues. Maintainers may also remove the stale label at their discretion. Thank you!

github-actions[bot] avatar Sep 01 '23 00:09 github-actions[bot]