使用 terraform 动态连接到 GKE 集群

Connect to GKE cluster dynamically using terraform

我正在使用 Terraform 脚本启动 GKE 集群,然后使用 helm 3 在集群上安装 splunk 连接器。

如何动态连接到 terraform kubernetes 提供程序中新创建的集群?

让提供商依赖集群证书:

data "google_client_config" "terraform_config" {
  provider = google
}

provider "kubernetes" {
  load_config_file = false
  host = "https://${google_container_cluster.my_cluster.endpoint}"
  cluster_ca_certificate = base64decode(google_container_cluster.my_cluster.master_auth[0].cluster_ca_certificate)
  token = data.google_client_config.terraform_config.access_token
}