【发布时间】:2021-02-03 01:15:10
【问题描述】:
我正在尝试为 terraform 模块添加 kubectl 提供程序,并遵循来自 Terraform kubectl 的文档。我运行terraform init 并成功安装了提供程序,但是当我尝试添加示例配置时,例如:(或来自here 的其他人)
resource "kubectl_server_version" "current" {}
然后运行 terraform plan 我得到以下消息:
Error: Could not load plugin
Failed to instantiate provider "registry.terraform.io/hashicorp/kubectl" to
obtain schema: unknown provider "registry.terraform.io/hashicorp/kubectl"
当我 tun terraform init(资源在模块 k8s 中到位)
Error: Failed to install provider
Error while installing hashicorp/kubectl: provider registry
registry.terraform.io does not have a provider named
registry.terraform.io/hashicorp/kubectl
一些输出:
$terraform plugins
├── provider[registry.terraform.io/hashicorp/kubernetes] 1.13.2
├── provider[registry.terraform.io/gavinbunney/kubectl] 1.9.1
├── module.k8s
│ ├── provider[registry.terraform.io/hashicorp/kubectl]
│ └── provider[registry.terraform.io/hashicorp/kubernetes]
$terraform init
Initializing modules...
Initializing the backend...
Initializing provider plugins...
- Using previously-installed hashicorp/kubernetes v1.13.2
- Using previously-installed gavinbunney/kubectl v1.9.1
$terraform -v
Terraform v0.13.4
+ provider registry.terraform.io/gavinbunney/kubectl v1.9.1
+ provider registry.terraform.io/hashicorp/kubernetes v1.13.2
....
一些配置文件:
terraform.tf
terraform {
required_version = "0.13.4"
backend "gcs" {
...
}
required_providers {
kubernetes = {
source = "hashicorp/kubernetes"
version = "1.13.2"
}
kubectl = {
source = "gavinbunney/kubectl"
version = "1.9.1"
}
....
terraform 成功初始化 gavinbunney/kubectl 提供程序,但是当我在 k8s.module 中添加 resource "kubectl_manifest" ... 时,terraform 正在尝试加载 hashicorp/kubectl 提供程序
我错过了什么? :)
【问题讨论】:
-
您说安装成功,但尝试安装时只显示错误。你认为安装成功后能显示输出吗?
-
terraform init 正在初始化模块...正在初始化后端...正在初始化提供程序插件... - 使用之前安装的 hashcorp/kubernetes v1.13.2 - 使用之前安装的 gavinbunney/kubectl v1.9.1
-
您能否编辑您的问题以将
terraform块定义也包含在required_providers中? -
terraform 成功初始化了
gavinbunney/kubectl,但是当我在 k8s.module 中添加kubectl_manifest资源时,terraform 正在尝试加载hashicorp/kubectl提供程序 -
您使用的是什么版本的 terraform?
terraform -v的输出是什么?
标签: kubernetes terraform kubectl terraform-provider-gcp