Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Diagnostic Setting defaults for Kubernetes Cluster #46

Merged
merged 2 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions modules/kubernetes-cluster/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.0
* Added `log_categories` and `metric_categories` variables to enable configuration of Diagnostic Settings.
* Changed default log categories.

## 1.2
* Added support for using an internal load balancer by granting the cluster managed identity the `Reader` and `Network Contributor` roles on the virtual network.

Expand Down
2 changes: 1 addition & 1 deletion modules/kubernetes-cluster/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2
2.0
36 changes: 10 additions & 26 deletions modules/kubernetes-cluster/src/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -70,36 +70,20 @@ resource "azurerm_monitor_diagnostic_setting" "main" {
target_resource_id = azurerm_kubernetes_cluster.main.id
log_analytics_workspace_id = var.log_analytics_workspace_id

enabled_log {
category = "kube-apiserver"
}

enabled_log {
category = "kube-audit"
}

enabled_log {
category = "kube-audit-admin"
}

enabled_log {
category = "kube-controller-manager"
}

enabled_log {
category = "kube-scheduler"
}
dynamic "enabled_log" {
for_each = var.log_categories

enabled_log {
category = "cluster-autoscaler"
content {
category = enabled_log.value
}
}

enabled_log {
category = "cloud-controller-manager"
}
dynamic "metric" {
for_each = var.metric_categories

metric {
category = "AllMetrics"
content {
category = metric.value
}
}
}

Expand Down
15 changes: 15 additions & 0 deletions modules/kubernetes-cluster/src/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ variable "log_analytics_workspace_id" {
type = string
}

# https://learn.microsoft.com/en-us/azure/azure-monitor/reference/supported-logs/microsoft-containerservice-managedclusters-logs
variable "log_categories" {
type = list(string)
default = [
"kube-scheduler"
]
}

variable "metric_categories" {
type = list(string)
default = [
"AllMetrics"
]
}

variable "network_plugin" {
type = string
default = "kubenet"
Expand Down
Loading