我正在尝试将 terraform kubernetes 提供程序升级到最新版本 2.7.1。以下是当前 terraform 配置的摘录:
terraform {
required_version = ">= 0.14.9"
required_providers {
aws = {
source = "hashicorp/aws"
version = "3.60.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
version = "2.5.0" # Trying to change this...
}
helm = {
source = "hashicorp/helm"
version = "2.3.0"
}
...
}
}
按照这些说明,我尝试了:
- 将版本更改为
>= 2.5.0
; - 将版本更改为
2.7.1
(甚至2.5.1
,仅用于测试);
并运行terraform init -upgrade
。不幸的是,尝试 (1) 没有效果,并且 (2) 给出了错误:
Upgrading modules...
[...]
Initializing the backend...
Initializing provider plugins...
- Finding hashicorp/kubernetes versions matching "2.5.0, >= 2.5.1"...
- Finding hashicorp/helm versions matching ">= 2.3.0, 2.3.0"...
[...]
- Using previously-installed hashicorp/helm v2.3.0
[...]
╷
│ Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider hashicorp/kubernetes: no available releases match the given constraints 2.5.0, >= 2.5.1
我尝试使用上述方法启动一个新项目(在一个空目录中),并且它正确安装了 version 2.7.1
,因此我认为问题在于预先存在的 terraform 状态。如何升级提供程序?