我正在尝试使用图像容器创建google_compute_instance_template。
在实例模板下的GUI上,您需要选中以下复选框: “将容器映像部署到此VM实例”
之后,我可以添加容器图像URI,并在高级选项上添加环境参数,参数等...
不幸的是,我没有从Terraform中找到方法。
感谢帮助。
答案 0 :(得分:0)
我认为您正在寻找这个Terraform模块-https://github.com/terraform-google-modules/terraform-google-container-vm
用法示例:
module "gce-container" {
source = "github.com/terraform-google-modules/terraform-google-container-vm"
version = "0.1.0"
container = {
image="gcr.io/google-samples/hello-app:1.0"
env = [
{
name = "TEST_VAR"
value = "Hello World!"
}
],
volumeMounts = [
{
mountPath = "/cache"
name = "tempfs-0"
readOnly = "false"
},
{
mountPath = "/persistent-data"
name = "data-disk-0"
readOnly = "false"
},
]
}
volumes = [
{
name = "tempfs-0"
emptyDir = {
medium = "Memory"
}
},
{
name = "data-disk-0"
gcePersistentDisk = {
pdName = "data-disk-0"
fsType = "ext4"
}
},
]
restart_policy = "Always"
}