From d196ee4ffce33099318fe6b1994282c99883bada Mon Sep 17 00:00:00 2001 From: Mark Simon <33624175+s1mark@users.noreply.github.com> Date: Mon, 2 Mar 2020 09:29:55 +0100 Subject: [PATCH] Flag option to enable OMS agent for AKS container monitoring (fixes #9) (#10) --- azurerm_kubernetes_cluster/README.md | 6 +++++- azurerm_kubernetes_cluster/aks.tf | 2 +- azurerm_kubernetes_cluster/variables.tf | 5 +++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/azurerm_kubernetes_cluster/README.md b/azurerm_kubernetes_cluster/README.md index 205b6e2..e2f206e 100644 --- a/azurerm_kubernetes_cluster/README.md +++ b/azurerm_kubernetes_cluster/README.md @@ -93,9 +93,13 @@ variable "agent_disk_size" { variable "log_analytics_workspace_sku" { type = string description = "The pricing level of the Log Analytics workspace (https://azure.microsoft.com/pricing/details/monitor)" - default = "PerGB2018" } +variable "aks_oms_agent" { + type = bool + description = "Enable Log Analytics agent to monitor containers" + default = false +} ``` ## Testing The `./test/fixtures/tf_module` contains an example on how to invoke the module. This is also wrapped around with `kitchen` which has the following configuration defined in `.kitchen.yaml` diff --git a/azurerm_kubernetes_cluster/aks.tf b/azurerm_kubernetes_cluster/aks.tf index fa38a7e..6badb60 100644 --- a/azurerm_kubernetes_cluster/aks.tf +++ b/azurerm_kubernetes_cluster/aks.tf @@ -51,7 +51,7 @@ resource "azurerm_kubernetes_cluster" "k8s" { } addon_profile { oms_agent { - enabled = true + enabled = var.aks_oms_agent log_analytics_workspace_id = azurerm_log_analytics_workspace.log-workspace.id } } diff --git a/azurerm_kubernetes_cluster/variables.tf b/azurerm_kubernetes_cluster/variables.tf index 4ae88cd..be3432c 100644 --- a/azurerm_kubernetes_cluster/variables.tf +++ b/azurerm_kubernetes_cluster/variables.tf @@ -77,3 +77,8 @@ variable "log_analytics_workspace_sku" { description = "The pricing level of the Log Analytics workspace (https://azure.microsoft.com/pricing/details/monitor)" default = "PerGB2018" } +variable "aks_oms_agent" { + type = bool + description = "Enable Log Analytics agent to monitor containers" + default = false +}