【发布时间】:2020-10-24 04:58:43
【问题描述】:
我正在尝试通过 Terraform 的 null_resource 创建/应用此 kubectl .yaml 文件 https://github.com/Azure/aad-pod-identity/blob/master/deploy/infra/deployment.yaml 到 AKS 以安装 Azure AD Pod Identity。它需要部署 Azure 网关入口控制器。 将 Windows 10 与 VS 代码一起使用
main.tf:
data "template_file" "aad_pod" {
template = "${file("${path.module}/templates/aad_pod.yaml")}"
}
resource "null_resource" "aad_pod_deploy" {
triggers = {
manifest_sha1 = "${sha1("${data.template_file.aad_pod.rendered}")}"
}
provisioner "local-exec" {
command = "kubectl apply -f -<<EOF\n${data.template_file.aad_pod.rendered}\nEOF"
}
}
应用 terraform 后出现此错误:
Error: Error running command 'kubectl apply -f -<<EOF
'cutted listing of yaml file'
EOF': exit status 1. Output: << was unexpected at this time.
任何帮助将不胜感激
【问题讨论】:
-
不知道是不是这个问题,但我总是在前后放一个空格
-
不幸的是它没有帮助:\
-
你知道“local-exec”对它用来运行命令的解释器使用“合理的默认值”吗? (见这里:terraform.io/docs/provisioners/local-exec.html#interpreter)。当您在 Windows 上时,我怀疑它是在 Bash 中执行,而是在 powershell 中执行。因此,就我而言,heredocs 不起作用。
-
您为什么不将其模板化到文件中,然后将 normal 值用于
-f参数:文件或 URL?
标签: kubernetes yaml terraform kubectl