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

Return status for kubernetes_resource

Open ar-qun opened this issue 2 years ago • 3 comments

Description

We are using Flux Receiver which is a CRD and reference it with the data source below:

The receiver ones deployed will set a URL in status. See https://fluxcd.io/docs/components/notification/receiver/#status

However Terraform doesn't really look into status.

Potential Terraform Configuration

CRD data source:

data "kubernetes_resource" "webhook-receiver" {
  api_version = "notification.toolkit.fluxcd.io/v1beta1"
  kind        = "Receiver"

  metadata {
    name      = "flux-system"
    namespace = "flux-system"
  }
}

Output of data.kubernetes_resource.webhook-receiver.object

{
  "apiVersion" = "notification.toolkit.fluxcd.io/v1beta1"
  "kind" = "Receiver"
  "metadata" = {
    "annotations" = tomap(null) /* of string */
    "clusterName" = tostring(null)
    "creationTimestamp" = tostring(null)
    "deletionGracePeriodSeconds" = tonumber(null)
    "deletionTimestamp" = tostring(null)
    "finalizers" = tolist(null) /* of string */
    "generateName" = tostring(null)
    "generation" = tonumber(null)
    "labels" = tomap({
      "kustomize.toolkit.fluxcd.io/name" = "flux-system"
      "kustomize.toolkit.fluxcd.io/namespace" = "flux-system"
    })
    "managedFields" = null /* tuple */
    "name" = "flux-system"
    "namespace" = "flux-system"
    "ownerReferences" = tolist(null) /* of object */
    "resourceVersion" = tostring(null)
    "selfLink" = tostring(null)
    "uid" = tostring(null)
  }
  "spec" = {
    "events" = tolist([
      "ping",
      "push",
    ])
    "resources" = tolist([
      {
        "apiVersion" = tostring(null)
        "kind" = "GitRepository"
        "matchLabels" = tomap(null) /* of string */
        "name" = "flux-system"
        "namespace" = tostring(null)
      },
    ])
    "secretRef" = {
      "name" = "webhook-token"
    }
    "suspend" = tobool(null)
    "type" = "github"
  }
}

References

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

ar-qun avatar Apr 25 '22 12:04 ar-qun

Contrary to what is stated in another issue (#1605), indeed the .status field is not present in the returned resource. This is a blocker in terraforming many CRs. I personally hit the case with OpenShift CustomDomain

pisto avatar May 20 '22 14:05 pisto

The culprit appears to be the unconditional removal of the status field here https://github.com/hashicorp/terraform-provider-kubernetes/blob/1340e20afebd531828df2e46836afda9bd5f922a/manifest/provider/resource.go#L182 . For a datasource, I don't see a reason to remove that.

pisto avatar May 20 '22 14:05 pisto

see my comment on https://github.com/hashicorp/terraform-provider-kubernetes/pull/1802#issuecomment-1248626868 - the delete(in, "status) is omitted in the PR, however I am not able to receive status from an object that definitely has one (here: Deployment in apps/v1).

balpert89 avatar Sep 15 '22 21:09 balpert89

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

github-actions[bot] avatar Dec 04 '22 02:12 github-actions[bot]