天蓝色 Linux vmss 扩展

azure Linux vmss extension

我已经为 Linux vmss 使用了新的 terraform 模块来将监控代理作为自定义扩展包括在内,但是,当一切都完成并手动重启 vmss 时,该实例没有 "Latest model"获得一个可用的更新模型,但我不想手动干预。以前的模块不需要手动重新映像以获得最新的模块。我错过了什么吗?

扩展程序的代码

 "azurerm_virtual_machine_scale_set_extension" "oms" {
 name                         = "OmsAgentForLinux"
 depends_on                   = [azurerm_linux_virtual_machine_scale_set.vmss]
 virtual_machine_scale_set_id = azurerm_linux_virtual_machine_scale_set.vmss.id
 publisher                    = "Microsoft.EnterpriseCloud.Monitoring"
 type                         = "OmsAgentForLinux"
 type_handler_version         = "1.11"
  settings = <<-BASE_SETTINGS
 {
  "workspaceId" : "xxxx"
 }
 BASE_SETTINGS

 protected_settings = <<-PROTECTED_SETTINGS
 {
 "workspaceKey" : "xxxxx"
  }
 PROTECTED_SETTINGS
 }

用于创建 azure vmss 的模块

  resource "azurerm_linux_virtual_machine_scale_set" "example" {
  name                = "example-vmss"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location
  sku                 = "Standard_F2"
  instances           = 1
  admin_username      = "administer"

 admin_ssh_key {
 username   = "administer"
 public_key = file("~/.ssh/id_rsa.pub")
  }

 source_image_reference {
 publisher = "Canonical"
 offer     = "UbuntuServer"
 version   = "latest"
  }

 os_disk {
  storage_account_type = "Standard_LRS"
 caching              = "ReadWrite"
  }

  network_interface {
  name    = "example"
  primary = true

    ip_configuration {
    name      = "internal"
    primary   = true
    subnet_id = azurerm_subnet.internal.id
     }
     }
    }

旧模块没有指定OS

 "azurerm_virtual_machine" "demovm"

这是预期的行为,因为默认情况下升级策略设置为手动。在此模式下,更新规模集模型时,现有 VM 不会发生任何变化。

来自 how to add an extension to all VMs in my virtual machine scale set,

If update policy is set to automatic, redeploying the template with the new extension properties updates all VMs.

If update policy is set to manual, first update the extension, and then manually update all instances in your VMs.

这种情况下,如果不想人工干预,可以尝试使用自动升级策略。

参考文献: