sl1pm4t / k2tf

Kubernetes YAML to Terraform HCL converter
Mozilla Public License 2.0
1.17k stars 108 forks source link

volumes.emptyDir is dropped causes diff #79

Closed so0k closed 2 years ago

so0k commented 3 years ago

command:

k2tf -f test-fixtures/replicationController.yml 

expected

resource "kubernetes_replication_controller" "es" {
  metadata {
    name = "es"

    labels = {
      component = "elasticsearch"
    }
  }

  spec {
    replicas = 1

    template {
      metadata {
        labels = {
          component = "elasticsearch"
        }
      }

      spec {
        volume {
          name = "storage"
          empty_dir {}
        }
...

got

resource "kubernetes_replication_controller" "es" {
  metadata {
    name = "es"

    labels = {
      component = "elasticsearch"
    }
  }

  spec {
    replicas = 1

    template {
      metadata {
        labels = {
          component = "elasticsearch"
        }
      }

      spec {
        volume {
          name = "storage"
        }
...

problem: this causes a diff in plan:

# kubernetes_replication_controller.es will be updated in-place
  ~ resource "kubernetes_replication_controller" "es" {
        id               = "default/es"
        # (1 unchanged attribute hidden)

      ~ spec {
            # (5 unchanged attributes hidden)

          ~ template {

              ~ spec {
                    # (12 unchanged attributes hidden)

                  ~ volume {
                        name = "storage"

                      - empty_dir {}
                    }
                    # (5 unchanged blocks hidden)
                }
                # (1 unchanged block hidden)
            }
            # (2 unchanged blocks hidden)
        }
        # (1 unchanged block hidden)
    }
so0k commented 3 years ago

I have no idea how k2tf works atm, I use it in make targets to automatically convert upstream bundles using kustomize into terraform modules, so I don't edit the generated results.

maybe this is related #29 ?