kubernetes - terraform 计划与 linode lke 一起挂在 github 操作上
问题描述
我正在尝试在 Github Actions 中使用 terraform 和 Linode 的 kubernetes 集群 (LKE),但是当我尝试运行plan
orapply
命令时遇到了问题——它们只是挂起。我的猜测是,因为terraform init
生成了terraform plan
无法访问的输出。但我不确定如何使该结果可用于下一步。
我的 github 操作工作流文件如下所示:
init-terraform:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: 'some-branch'
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
cli_config_credentials_token: ${{ secrets.TERRAFORM_API_TOKEN }}
- name: Terraform Init
run: terraform init
- name: Terraform Plan
run: terraform plan
- name: Terraform Apply
run: terraform apply -auto-approve
初始化似乎工作正常,但计划只是挂起。当我在本地运行它时,该计划大约需要 20 秒。
我main.tf
在 repo 中的文件如下所示:
terraform {
required_providers {
linode = {
source = "linode/linode"
version = "=1.16.0"
}
}
}
provider "linode" {
}
resource "linode_lke_cluster" "lke_cluster" {
label = "my-label"
k8s_version = "1.21"
region = "us-central"
pool {
type = "g6-standard-2"
count = 3
}
}
我已将其设置TERRAFORM_API_TOKEN
为 github 机密,并将其设置LINODE_TOKEN
为 terraform 环境变量。
我错过了什么导致 terraform 调用挂起?
解决方案
虽然,我不熟悉 linode 的提供者,但我有一种强烈的预感,你需要包括在内
with:
cli_config_credentials_token: ${{ secrets.TERRAFORM_API_TOKEN }}
在你的每一步。
推荐阅读
- python-3.x - 如何从以下列表中获得所需的输出?
- date - 有没有办法将两种不同的 dateTime 格式解析为 Java 中的 LocalDateTime 或 Instant?
- javascript - 如何在 Electron 中使用 GET 变量重定向到另一个 HTML 文件?
- r - 如何评估字符串是否是R中的英文单词
- db2 - COBOL DB2 绑定过程
- java - Java:ClassNotFound 类路径问题
- javascript - 如何在 webgl 中用纹理相等地包裹四边形
- c# - 重新启动后自动启动 Microsoft Reporting Services
- c# - 在不退出循环 C# 的情况下验证来自控制台的输入值
- reactjs - 在功能组件中返回 React.createElement 时,“函数作为反应子无效”