Terraform GCE和kubernetes

时间:2017-10-16 21:03:18

标签: kubernetes terraform google-compute-engine

我使用terraform配置Google容器引擎,我也使用terraform Kubernetes提供程序。我在私人仓库上有一些docker图像,我喜欢使用kubernetes提供程序来拉,但是我使用image_pull_secrets有些困难。

resource "kubernetes_service_account" "example" {
  metadata {
    name = "terraform-example"
  }
  secret {
    name = "${kubernetes_secret.example.metadata.0.name}"
  }
}

resource "kubernetes_secret" "example" {
  metadata {
    name = "terraform-example"
  }
}

我想知道我应该为image_pull_secrets使用什么。

  resource "kubernetes_replication_controller" "xxx-rest-client" {
    metadata {
      name = "xxx-rest-client"
      labels {
        app = "xxx-rest-client"
      }
    }
    spec {
      replicas = 2
      selector {
        name = "xxx-rest-client"
      }
      template {
        image_pull_secrets   = ["${kubernetes_service_account.example.UNKNOWN}"]
        container {
          image               = "test/xxx-rest-client"
          name                = "xxx-rest-client"
          //port  = ["3128"]

          resources{
            limits{
              cpu    = "1.0"
              memory = "512Mi"
            }
            requests{
              cpu    = "250m"
              memory = "50Mi"
            }
          }
        }
      }
    }
     depends_on = ["google_container_cluster.xxx"]
  }

1 个答案:

答案 0 :(得分:0)

拉取秘密列表的每个元素都需要是一张地图。

image_pull_secrets = [
  {
    name = "${kubernetes_service_account.example.default_secret_name}"
  }
]

尝试一下它应该适合你。