为什么Terraform停止了GCP项目的工作

时间:2018-01-26 10:41:22

标签: terraform gcp google-kubernetes-engine

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

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文件无效。

从谷歌插件1.4升级到1.5后发生了这种情况 我的mac从那时起就重新启动了。

2 个答案:

答案 0 :(得分:0)

我最后删除了.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
再次

并完成部署。

因为我有很好的连接性 这对我来说就像一个google插件bug。

答案 1 :(得分:0)

在我的情况下,尝试为刚创建的群集(通过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" { ... }