Created
March 30, 2022 13:54
-
-
Save keviocastro/dade9afefe4f7b40002dbccd25b11b82 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "azurerm_resource_group" "k8s" { | |
name = var.resource_group_name | |
location = var.location | |
} | |
resource "random_id" "log_analytics_workspace_name_suffix" { | |
byte_length = 8 | |
} | |
resource "azurerm_log_analytics_workspace" "dev_analytics_workspace" { | |
# The WorkSpace name has to be unique across the whole of azure, not just the current subscription/tenant. | |
name = "${var.log_analytics_workspace_name}-${random_id.log_analytics_workspace_name_suffix.dec}" | |
location = var.log_analytics_workspace_location | |
resource_group_name = azurerm_resource_group.k8s.name | |
sku = var.log_analytics_workspace_sku | |
} | |
resource "azurerm_log_analytics_solution" "dev_log_analytics" { | |
solution_name = "ContainerInsights" | |
location = azurerm_log_analytics_workspace.dev_analytics_workspace.location | |
resource_group_name = azurerm_resource_group.k8s.name | |
workspace_resource_id = azurerm_log_analytics_workspace.dev_analytics_workspace.id | |
workspace_name = azurerm_log_analytics_workspace.dev_analytics_workspace.name | |
plan { | |
publisher = "Microsoft" | |
product = "OMSGallery/ContainerInsights" | |
} | |
} | |
resource "azurerm_kubernetes_cluster" "k8s" { | |
name = var.cluster_name | |
location = azurerm_resource_group.k8s.location | |
resource_group_name = azurerm_resource_group.k8s.name | |
dns_prefix = var.dns_prefix | |
linux_profile { | |
admin_username = "ubuntu" | |
ssh_key { | |
key_data = file(var.ssh_public_key) | |
} | |
} | |
default_node_pool { | |
name = "devpool" | |
node_count = var.agent_count | |
vm_size = "Standard_D2_v2" | |
vnet_subnet_id = module.network[0].subnet_private.id | |
} | |
service_principal { | |
client_id = var.client_id | |
client_secret = var.client_secret | |
} | |
addon_profile { | |
oms_agent { | |
enabled = true | |
log_analytics_workspace_id = azurerm_log_analytics_workspace.dev_analytics_workspace.id | |
} | |
} | |
# network_profile { | |
# load_balancer_sku = "Standard" | |
# network_plugin = "kubenet" | |
# } | |
tags = { | |
Environment = "Development" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment