【问题标题】:Failed to construct REST client构建REST客户端失败
【发布时间】:2021-07-25 22:57:00
【问题描述】:

我正在尝试在 Terraform 中使用 kubernetes-alpha 提供程序,但出现“无法构建 REST 客户端”错误消息。 我正在使用 tfk8s 将我的 yaml 文件转换为 terraform 代码。

我比 kubernetes 为提供者做 seme 声明,我的 kubernetes 提供者工作正常

provider "kubernetes-alpha" {
  host                   = "https://${data.google_container_cluster.primary.endpoint}"
  token                  = data.google_client_config.default.access_token
  cluster_ca_certificate = base64decode(data.google_container_cluster.primary.master_auth[0].cluster_ca_certificate)
}

provider "kubernetes" {
  host                   = "https://${data.google_container_cluster.primary.endpoint}"
  token                  = data.google_client_config.default.access_token
  cluster_ca_certificate = base64decode(data.google_container_cluster.primary.master_auth[0].cluster_ca_certificate)
}
resource "kubernetes_manifest" "exemple" {
  provider = kubernetes-alpha
  manifest = {
     # result of tfk8s
  }
}

the error message

有人可以帮忙吗?

【问题讨论】:

  • 在我的一个环境中,这已经发生了数周。 Hashicorp 似乎一无所知
  • 在成功应用自定义资源并通过 terraform destroy 销毁特定 terraform 创建的 kubernetes 集群后,我也发生了这种情况。奇怪的是,我的自定义资源也是一个证书管理器 clusterIssuer 对象。

标签: kubernetes terraform google-kubernetes-engine terraform-provider-gcp terraform-provider-kubernetes


【解决方案1】:

经过一番挖掘,我发现这个资源需要一个运行的 kubernetes 实例和配置,然后 terraform 计划才能正常工作。最好在 github 中说明:https://github.com/hashicorp/terraform-provider-kubernetes-alpha/issues/199#issuecomment-832614387

基本上,您必须有两个步骤,首先 terraform 应用您的主要配置以在您的云中建立 kubernetes,然后在该集群建立后 terraform 应用 CRD 资源。

编辑:我仍在尝试学习管理 terraform 配置的良好模式/实践,发现这很有帮助。 How to give a .tf file as input in Terraform Apply command?。我最终只是将证书管理器 CRD 保留为标准 kubernetes 清单 yaml,我将每个集群与其他应用程序 helm 图表一起应用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-23
    • 2017-01-11
    • 1970-01-01
    • 2012-11-20
    • 1970-01-01
    • 2011-08-20
    相关资源
    最近更新 更多