【问题标题】:Why has Terraform stopped working on GCP project为什么 Terraform 停止了 GCP 项目的工作
【发布时间】:2018-07-05 16:47:05
【问题描述】:

我有一个 terraform 部署,它在 GCP 上部署了 GKE 集群池,但它停止了工作。

Error: Error applying plan:

1 error(s) occurred:

* google_container_cluster.primary: 1 error(s) occurred:

* google_container_cluster.primary: Post 
https://container.googleapis.com/v1/projects/...-gcp-poc/zones/europe-
west1-d/clusters?alt=json: dial tcp: i/o timeout

我仍然可以通过控制台手动部署

我仍然可以使用 gcloud cli 部署它

gcloud container clusters create cluster_name --zone europe-west1-b

我尝试更改凭据 json 文件无济于事。

从 google 插件 1.4 升级到 1.5 后发生 从那以后,我的 mac 重新启动了。

【问题讨论】:

  • 如果你卷曲那个端点会发生什么?看起来它只是超时,这表明防火墙/网络连接。
  • { "error": { "code": 401, "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See developers.google.com/identity/sign-in/web/devconsole-project .", "状态": "未认证" } } .我需要安排 http 请求

标签: terraform gcp google-kubernetes-engine


【解决方案1】:

我最终删除了 .terraform 文件夹并将其替换为使用 google 插件 1.4 的旧文件夹

terraform init
terraform plan
terraform apply

即使我收到此错误,这仍然有效:

Error: Error applying plan:

1 error(s) occurred:

* google_container_cluster.rtp_container_cluster: 1 error(s) occurred:

* google_container_cluster.rtp_container_cluster: Error reading 
instance group manager returned as an instance group URL: Get 
https://www.googleapis.com/compute/v1/projects/rtp-gcp-
poc/zones/europe-west1-b/instanceGroupManagers/gke-rtp-container-
cluste-default-pool-8bb9aa85-grp?alt=json: dial tcp: i/o timeout

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

然后我通过 kubectl 连接

➜  ~ kubectl get node
NAME                                                  STATUS    ROLES     
AGE       VERSION
gke-...-container-cluste-default-pool-8bb9aa85-7kcb   Ready     <none>    
14m       v1.8.6-gke.0

我试过了

terraform apply

再次部署完成。

因为我有很好的连接性 这对我来说就像一个谷歌插件错误。

【讨论】:

    【解决方案2】:

    就我而言,当我尝试为刚刚创建的集群(通过 terraform)创建部署时遇到错误 (Error: Failed to create deployment: Post https://32.244.226.151/apis/apps/v1/namespaces/default/deployments: dial tcp 35.242.229.150:443: i/o timeout)。

    为我解决问题的方法是将 kubctl 重新连接到集群:

    gcloud container clusters list
    gcloud container clusters get-credentials PUT_CLUSTER_NAME_HERE

    更新: 我添加了这个:

    provider "kubernetes" {
       host     = "${google_container_cluster.primary.endpoint}"
       client_certificate     = "${base64decode(google_container_cluster.primary.master_auth.0.client_certificate)}"
       client_key             = "${base64decode(google_container_cluster.primary.master_auth.0.client_key)}"
       cluster_ca_certificate = "${base64decode(google_container_cluster.primary.master_auth.0.cluster_ca_certificate)}"
    }
    

    /**
     * Submit the job - Terraform doesn't yet support StatefulSets, so we have to
     * shell out.
     * See: https://github.com/sethvargo/vault-on-gke/blob/master/terraform/gcp.tf
     */
    resource "null_resource" "apply" {
    
      depends_on = ["google_container_node_pool.primary_preemptible_nodes"]
        provisioner "local-exec" {
        command = <<EOF
    gcloud container clusters get-credentials "${google_container_cluster.primary.name}" \
      --project="${google_container_cluster.primary.project}"
    
    gcloud container clusters list
    EOF
      }
    }
    

    解决了我的问题。 注意:我的集群资源是resource "google_container_cluster" "primary" { ... }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-30
      • 2018-01-19
      相关资源
      最近更新 更多