gpt4 book ai didi

azure - Terraform Azure 容器组似乎无法挂载多个卷?

转载 作者:行者123 更新时间:2023-12-04 16:38:11 25 4
gpt4 key购买 nike

在查看 Azure 容器组的文档时,特别是有关 secret 的此页面:https://learn.microsoft.com/en-us/azure/container-instances/container-instances-volume-secret我注意到卷对象是一个由 1 个或多个卷组成的数组。

"volumes": [
{
"name": "secretvolume1",
"secret": {
"mysecret1": "TXkgZmlyc3Qgc2VjcmV0IEZPTwo=",
"mysecret2": "TXkgc2Vjb25kIHNlY3JldCBCQVIK"
}
}
]

在此处查看 Terraform 文档时:https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/container_group我注意到体积对象是单一的。

是否无法在 terraform 中制作多个卷?尽管在文档中似乎如此,但在 ARM 中这是否也是不可能的?测试表明 Terraform 不支持多个卷,尽管我对 ARM 的了解还不足以验证。

最佳答案

当然,可以使用 Terraform 制作多个卷:

在我的工作示例中,它创建了两个卷,一个用于存储文件共享,另一个是 secret 卷。

resource "azurerm_resource_group" "example" {
name = "${var.prefix}-resources"
location = var.location
}

resource "azurerm_storage_account" "example" {
name = "${var.prefix}stor"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
account_tier = "Standard"
account_replication_type = "LRS"
}

resource "azurerm_storage_share" "example" {
name = "aci-test-share"
storage_account_name = azurerm_storage_account.example.name
quota = 50
}

resource "azurerm_container_group" "example" {
name = "${var.prefix}-continst"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
ip_address_type = "public"
dns_name_label = "${var.prefix}-continst"
os_type = "Linux"

container {
name = "hello-world"
image = "microsoft/aci-helloworld:latest"
cpu = "0.5"
memory = "1.5"

ports {
port = 443
protocol = "TCP"
}

volume {
name = "logs"
mount_path = "/aci/logs"
read_only = false
share_name = azurerm_storage_share.example.name

storage_account_name = azurerm_storage_account.example.name
storage_account_key = azurerm_storage_account.example.primary_access_key

}

volume {
name = "secretvolume1"
mount_path = "/mnt/secrets"
read_only = false

secret = {
"mysecret1"=base64encode("My first secret FOO")
"mysecret2"=base64encode("My second secret BAR")
}
}
}

}

我正在使用最新的提供商。

PS D:\Terraform> .\terraform.exe -v
Terraform v0.14.7
+ provider registry.terraform.io/hashicorp/azurerm v2.48.0

enter image description here

验证 Azure 门户上容器实例--->连接--->/bin/sh 的装载路径。

enter image description here

关于azure - Terraform Azure 容器组似乎无法挂载多个卷?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66338042/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com