Terraform-provider-kubernetes: Pod metadata not inherited from parent deployment

Created on 12 Sep 2019  ·  9Comments  ·  Source: hashicorp/terraform-provider-kubernetes

Terraform Version

v0.11.14

Affected Resource(s)

deployments

Terraform Configuration Files

resource "kubernetes_deployment" "whoami" {
  metadata {
    name      = "whoami"
    namespace = "${kubernetes_namespace.whoami.metadata.0.name}"

    labels {
      app = "whoami"
    }
  }

  spec {
    replicas = "1"

    selector {
      match_labels = {
        app = "whoami"
      }
    }

    template {
      metadata {
        labels {
          app  = "whoami"
        }
      }

      spec {
        container {
          image = "containous/whoami"
          name  = "whoami"

          port {
            name           = "http"
            container_port = 80
            protocol       = "TCP"
          }
        }
      }
    }
  }
}

Debug Output

When I do a terraform plan the resource which was previously created and imported in state is changed :

spec.0.template.0.metadata.0.namespace:   "" => "default" (forces new resource)

Expected Behavior

The namespace in the pod template should be inherited from the parent resource (deployment)
Or empty if already defined in the parent.

Actual Behavior

resource is recreated and the pod is running in the deployment namespace (not default)
Is it normal ?
maybe the default value for namespace in namespacedMetada should be "" instead of "default" ?

bug

All 9 comments

OK, I didn't see that, sorry.

WoW this is huge I think it's causing a bug one of my deployments! Thanks for the PR @pdecat!!
Please can someone approve this?? Please!!

The PR got merged so when it's going to be released?

I'll cut a release before the end of the week.

Hi,
I'm using latest (1.11.1) version, but I'm still getting this issue.

Hi @odedpriva, would you mind sharing your resource's terraform configuration and the exact plan you're seing?

I cannot reproduce this issue anymore. Closing.

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

Was this page helpful?
0 / 5 - 0 ratings