我正在创建一个类似这样的GKE集群,身份验证设置如下:
master_auth {
# Setting an empty username and password explicitly disables basic auth
username = ""
password = ""
# Whether client certificate authorization is enabled for this cluster.
client_certificate_config {
issue_client_certificate = false
}
}创建集群后,我将使用另一个提供程序来安装helm charts:
provider "helm" {
kubernetes {
host = ...
}
tiller_image = "gcr.io/kubernetes-helm/tiller:v2.14.1"
}我的问题是,如何用集群创建步骤中可能获得的身份验证信息填充kubernetes块?
发布于 2019-06-30 06:39:15
您可以插值这些值来设置提供程序,就像在Terraform中设置任何其他内容一样。
因此,在您的示例中,您可以使用类似以下内容:
resource "google_container_cluster" "cluster" {
# ...
}
provider "helm" {
kubernetes {
host = "https://${google_container_cluster.cluster.endpoint}"
username = "${google_container_cluster.cluster.master_auth.0.username}"
password = "${google_container_cluster.cluster.master_auth.0.password}"
client_certificate = "${google_container_cluster.cluster.master_auth.0.client_certificate}"
client_key = "${google_container_cluster.cluster.master_auth.0.client_key}"
cluster_ca_certificate = "${google_container_cluster.cluster.master_auth.0.cluster_ca_certificate}"
}
}注意,并不是所有的提供者都可以从不存在的资源中插入,因为一些提供者在提供者初始化期间进行特征检测,这发生在依赖图需要使用提供者之前。Postgresql提供程序就是一个这样的例子。一旦资源已经创建,这些提供者仍然可以使用该资源,或者,如果依赖资源是在另一个上下文/状态文件中创建的,则它们可以使用数据源来访问信息。
https://stackoverflow.com/questions/56820581
复制相似问题