The following terraform resource creates an AKS cluster with a Virtual Machine Scale Set (VMSS) and a Load Balancer (LB) resource. Currently, diagnostic logs are enabled on the cluster resource by adding oms_agent section under addon_profile.
However, the documentation does not mention if there is a way to enable diagnostics on the VMSS created by default_node_pool and LB created by network_profile. Is this possible via terraform?
Alternatively, is there a fixed naming scheme for the VMSS and LB created by the cluster? If there is a fixed naming scheme, one solution to this problem would be to simply look for resources with these predefined names in the correct resource group to create log analytics solution.
Terraform Documentation:
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/kubernetes_cluster
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/kubernetes_cluster#default_node_pool
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/kubernetes_cluster#load_balancer_profile
resource "azurerm_kubernetes_cluster" "aks-cluster" {
resource_group_name = azurerm_resource_group.aks-rg.name
location = azurerm_resource_group.aks-rg.location
name = "my-cluster"
dns_prefix = "my-cluster-aks"
kubernetes_version = "1.18.8"
private_cluster_enabled = false
node_resource_group = "MC_my-cluster-aks"
api_server_authorized_ip_ranges = [var.authorized_ip]
service_principal {
client_id = var.sp_client_id
client_secret = var.client_secret
}
default_node_pool {
name = "default"
type = "VirtualMachineScaleSets"
vm_size = "Standard_D2_v2"
node_count = 4
enable_auto_scaling = true
min_count = 4
max_count = 6
vnet_subnet_id = azurerm_subnet.aks-vnet-subnet.id
}
network_profile {
network_plugin = "azure"
network_policy = "azure"
docker_bridge_cidr = var.aks_docker_bridge_cidr
dns_service_ip = var.aks_dns_service_ip
load_balancer_sku = "standard"
service_cidr = var.aks_service_cidr
}
addon_profile {
oms_agent {
enabled = true
log_analytics_workspace_id = azurerm_log_analytics_workspace.aks_log_ws.id
}
}
}