无法通过 terraform 为 aks 设置 azure 日志监控

问题描述 投票:0回答:1

无法通过 terraform 为 aks 设置 azure 日志记录并出现此错误

解决方案名称:“logsMonitoring(*********):执行CreateOrUpdate: 意外状态 400,错误:InvalidParameter:解决方案产品 名称不能以“OMSGallery/”开头,因为它 │ 是为 Microsoft 保留的 第一方解决方案

resource "azurerm_log_analytics_solution" "aks-logs" {
  solution_name = "logsMonitoring"
  location = var.location
  resource_group_name = var.resource_group_name
  workspace_resource_id = azurerm_log_analytics_workspace.aks-monitoring.id
  workspace_name = azurerm_log_analytics_workspace.aks-monitoring.name
  tags = local.tags
  plan {
    publisher = "Microsoft"
    product   = "OMSGallery/ContainerInsights"
  }
}

尝试更新解决方案名称并验证

azure terraform
1个回答
0
投票

我尝试通过 terraform 为 aks 设置 azure 日志监控,并且能够成功满足要求。

根据您遇到的错误消息和您提供的 Terraform 配置,问题似乎与

solution_name
product
资源中的
azurerm_log_analytics_solution
字段有关。错误消息表明产品名称不得以“OMSGallery/”开头,因为此前缀是为 Microsoft 第一方解决方案保留的。

问题的一个可能原因是

product
块中的
plan
字段,其值为
"OMSGallery/ContainerInsights"
。对我有用的解决方案是将解决方案名称的名称更改为“ContainerInsights”。

我的演示地形配置:

provider "azurerm" {
  features {}
}
resource "azurerm_resource_group" "example" {
  name     = "vksb-aks-rg"
  location = "East US"
}
resource "azurerm_log_analytics_workspace" "example" {
  name                = "vksb-log-analytics"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  sku                 = "PerGB2018"
}
resource "azurerm_kubernetes_cluster" "aks" {
  name                = "vksb-aks-cluster"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  dns_prefix          = "exampleaks"

  default_node_pool {
    name       = "default"
    node_count = 1
    vm_size    = "Standard_DS2_v2"
  }

  identity {
    type = "SystemAssigned"
  }

   
    oms_agent {
      log_analytics_workspace_id = azurerm_log_analytics_workspace.example.id
    }
  
}
resource "azurerm_log_analytics_solution" "aks_solution" {
  solution_name         = "ContainerInsights"
  location              = azurerm_resource_group.example.location
  resource_group_name   = azurerm_resource_group.example.name
  workspace_resource_id = azurerm_log_analytics_workspace.example.id
  workspace_name        = azurerm_log_analytics_workspace.example.name

  plan {
    publisher = "Microsoft"
    product   = "OMSGallery/ContainerInsights"
  }
}

输出:

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.