Reputation: 75
I have this error when trying to mount a volume in azure container apps with terraform. Everything looks configured properly as per the documentation, so I'm wondering if anyone has any ideas what could be wrong?
{"TimeStamp":"2024-08-21 15:41:18 \u002B0000 UTC","Type":"Warning","ContainerAppName":"pyapi","RevisionName":"pyapi--hi0d6li","ReplicaName":"pyapi--hi0d6li-7cc8bbcdc5-rjw5x","Msg":"Container \u0027api\u0027 was terminated with exit code \u0027\u0027 and reason \u0027VolumeMountFailure\u0027. One or more errors occurred. (Shell command exited with non-zero status code. StatusCode = 32 | StdOut = | StdErr = mount error(13): Permission denied\nRefer to the mount.cifs(8) manual page (e.g. man mount.cifs) and kernel log messages (dmesg)\n) (Shell command exited with non-zero status code. StatusCode = 32 | StdOut = | StdErr = mount error(13): Permission denied\nRefer to the mount.cifs(8) manual page (e.g. man mount.cifs) and kernel log messages (dmesg)\n)","Reason":"ContainerTerminated","EventSource":"ContainerAppController","Count":5}
below the code TF
#api.tf
data "azurerm_user_assigned_identity" "pyapi_id" {
name = "fkallel-aca-id"
resource_group_name = data.azurerm_resource_group.rg.name
}
resource "azurerm_container_app" "pyapi" {
name = "pyapi"
container_app_environment_id = azurerm_container_app_environment.fk-apps-env.id
resource_group_name = data.azurerm_resource_group.rg.name
revision_mode = "Single"
workload_profile_name = "Consumption"
template {
container {
name = "api"
image = "docker.io/nginx:latest"
cpu = 0.25
memory = "0.5Gi"
volume_mounts {
name = "nfsv"
path = "/data"
}
}
volume {
name = "nfsv"
storage_name = "nfs"
storage_type = "AzureFile"
}
}
ingress {
allow_insecure_connections = false
external_enabled = true
target_port = 8080
transport = "auto"
traffic_weight {
latest_revision = true
percentage = 100
}
}
identity {
type = "UserAssigned"
identity_ids = [data.azurerm_user_assigned_identity.pyapi_id.id]
}
}
Upvotes: 0
Views: 463
Reputation: 2401
Azure Container Apps: Volume mount fails using terraform
The main issue is the container is the because permission issue with the NFS volume you're trying to mount in the Azure Container App because of network port.
As per the MSDoc we should provide the access for the container to access the shared files by allowing port 80.
Configuration:
resource "azurerm_storage_account" "example" {
account_replication_type = "LRS"
account_tier = "Standard"
location = azurerm_resource_group.example.location
name = "tetshvhkstostorageacct"
resource_group_name = azurerm_resource_group.example.name
}
resource "azurerm_storage_share" "example" {
name = "nfsvk-share"
quota = 50
storage_account_name = azurerm_storage_account.example.name
}
resource "azurerm_container_app_environment" "example" {
location = azurerm_resource_group.example.location
name = "fkvk-apps-env"
resource_group_name = azurerm_resource_group.example.name
}
resource "azurerm_container_app" "example" {
container_app_environment_id = azurerm_container_app_environment.example.id
name = "testsamplevksb"
resource_group_name = azurerm_resource_group.example.name
revision_mode = "Single"
ingress {
external_enabled = true
target_port = 80
traffic_weight {
latest_revision = true
percentage = 100
}
}
template {
max_replicas = 1
container {
cpu = 0.5
image = "nginx"
memory = "1Gi"
name = "testsamplevksb"
volume_mounts {
name = "vkazurefil4olume"
path = "/var/log/nginx"
}
}
volume {
name = "vkazurefil4olume"
storage_name = "venkatvk"
storage_type = "AzureFile"
}
}
depends_on = [
azurerm_container_app_environment.example, azurerm_storage_account.example, azurerm_storage_share.example
]
}
resource "azurerm_container_app_environment_storage" "example" {
access_key = azurerm_storage_account.example.primary_access_key
access_mode = "ReadWrite"
account_name = azurerm_storage_account.example.name
container_app_environment_id = azurerm_container_app_environment.example.id
name = "venkatvk"
share_name = "nfsvk-share"
depends_on = [
azurerm_container_app_environment.example, azurerm_storage_account.example
]
}
Deployment:
Refer:
Tutorial: Create an Azure Files volume mount in Azure Container Apps | Microsoft Learn
Upvotes: 0