From 08993aed7b20d6f9120f157846837268747a6317 Mon Sep 17 00:00:00 2001 From: Sergei Kolobov Date: Wed, 5 Apr 2023 01:35:44 +0200 Subject: [PATCH 1/4] feat: add support for image cleaner --- main.tf | 2 ++ variables.tf | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/main.tf b/main.tf index dffe5878..c0604a32 100644 --- a/main.tf +++ b/main.tf @@ -23,6 +23,8 @@ resource "azurerm_kubernetes_cluster" "main" { disk_encryption_set_id = var.disk_encryption_set_id dns_prefix = var.prefix http_application_routing_enabled = var.http_application_routing_enabled + image_cleaner_enabled = var.image_cleaner_enabled + image_cleaner_interval_hours = var.image_cleaner_interval_hours kubernetes_version = var.kubernetes_version local_account_disabled = var.local_account_disabled node_resource_group = var.node_resource_group diff --git a/variables.tf b/variables.tf index 9929c12b..e0284404 100644 --- a/variables.tf +++ b/variables.tf @@ -462,6 +462,18 @@ variable "identity_type" { } } +variable "image_cleaner_enabled" { + type = bool + description = "(Optional) Specifies whether Image Cleaner is enabled." + default = false +} + +variable "image_cleaner_interval_hours" { + type = number + description = "(Optional) Specifies the interval in hours when images should be cleaned up." + default = 48 +} + variable "ingress_application_gateway_enabled" { type = bool default = false From 72bd0b36da1e5f26487547c22d5fe46a6dee21e6 Mon Sep 17 00:00:00 2001 From: Sergei Kolobov Date: Wed, 5 Apr 2023 09:48:14 +0200 Subject: [PATCH 2/4] fix: make image_cleaner_interval_hours optional --- main.tf | 2 +- variables.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/main.tf b/main.tf index c0604a32..b8865975 100644 --- a/main.tf +++ b/main.tf @@ -24,7 +24,7 @@ resource "azurerm_kubernetes_cluster" "main" { dns_prefix = var.prefix http_application_routing_enabled = var.http_application_routing_enabled image_cleaner_enabled = var.image_cleaner_enabled - image_cleaner_interval_hours = var.image_cleaner_interval_hours + image_cleaner_interval_hours = var.image_cleaner_enabled && var.image_cleaner_interval_hours != null ? var.image_cleaner_interval_hours : null kubernetes_version = var.kubernetes_version local_account_disabled = var.local_account_disabled node_resource_group = var.node_resource_group diff --git a/variables.tf b/variables.tf index e0284404..531e5e34 100644 --- a/variables.tf +++ b/variables.tf @@ -471,7 +471,7 @@ variable "image_cleaner_enabled" { variable "image_cleaner_interval_hours" { type = number description = "(Optional) Specifies the interval in hours when images should be cleaned up." - default = 48 + default = null } variable "ingress_application_gateway_enabled" { From 7743eb25753a44b52fad5eadcc0800d246625f7e Mon Sep 17 00:00:00 2001 From: Sergei Kolobov Date: Mon, 30 Oct 2023 01:00:01 +0100 Subject: [PATCH 3/4] docs: update README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 6a3e631d..32530ba9 100644 --- a/README.md +++ b/README.md @@ -307,6 +307,8 @@ No modules. | [http\_application\_routing\_enabled](#input\_http\_application\_routing\_enabled) | Enable HTTP Application Routing Addon (forces recreation). | `bool` | `false` | no | | [identity\_ids](#input\_identity\_ids) | (Optional) Specifies a list of User Assigned Managed Identity IDs to be assigned to this Kubernetes Cluster. | `list(string)` | `null` | no | | [identity\_type](#input\_identity\_type) | (Optional) The type of identity used for the managed cluster. Conflicts with `client_id` and `client_secret`. Possible values are `SystemAssigned` and `UserAssigned`. If `UserAssigned` is set, an `identity_ids` must be set as well. | `string` | `"SystemAssigned"` | no | +| [image\_cleaner\_enabled](#input\_image\_cleaner\_enabled) | (Optional) Specifies whether Image Cleaner is enabled. | `bool` | `false` | no | +| [image\_cleaner\_interval\_hours](#input\_image\_cleaner\_interval\_hours) | (Optional) Specifies the interval in hours when images should be cleaned up. | `number` | `null` | no | | [ingress\_application\_gateway\_enabled](#input\_ingress\_application\_gateway\_enabled) | Whether to deploy the Application Gateway ingress controller to this Kubernetes Cluster? | `bool` | `false` | no | | [ingress\_application\_gateway\_id](#input\_ingress\_application\_gateway\_id) | The ID of the Application Gateway to integrate with the ingress controller of this Kubernetes Cluster. | `string` | `null` | no | | [ingress\_application\_gateway\_name](#input\_ingress\_application\_gateway\_name) | The name of the Application Gateway to be used or created in the Nodepool Resource Group, which in turn will be integrated with the ingress controller of this Kubernetes Cluster. | `string` | `null` | no | From 99803f7459dec967a852f846498cad2583564533 Mon Sep 17 00:00:00 2001 From: zjhe Date: Thu, 2 Nov 2023 15:48:26 +0800 Subject: [PATCH 4/4] update variable's default value and description, simplify the assignment --- README.md | 2 +- main.tf | 2 +- variables.tf | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 32530ba9..5447c0c7 100644 --- a/README.md +++ b/README.md @@ -308,7 +308,7 @@ No modules. | [identity\_ids](#input\_identity\_ids) | (Optional) Specifies a list of User Assigned Managed Identity IDs to be assigned to this Kubernetes Cluster. | `list(string)` | `null` | no | | [identity\_type](#input\_identity\_type) | (Optional) The type of identity used for the managed cluster. Conflicts with `client_id` and `client_secret`. Possible values are `SystemAssigned` and `UserAssigned`. If `UserAssigned` is set, an `identity_ids` must be set as well. | `string` | `"SystemAssigned"` | no | | [image\_cleaner\_enabled](#input\_image\_cleaner\_enabled) | (Optional) Specifies whether Image Cleaner is enabled. | `bool` | `false` | no | -| [image\_cleaner\_interval\_hours](#input\_image\_cleaner\_interval\_hours) | (Optional) Specifies the interval in hours when images should be cleaned up. | `number` | `null` | no | +| [image\_cleaner\_interval\_hours](#input\_image\_cleaner\_interval\_hours) | (Optional) Specifies the interval in hours when images should be cleaned up. Defaults to `48`. | `number` | `48` | no | | [ingress\_application\_gateway\_enabled](#input\_ingress\_application\_gateway\_enabled) | Whether to deploy the Application Gateway ingress controller to this Kubernetes Cluster? | `bool` | `false` | no | | [ingress\_application\_gateway\_id](#input\_ingress\_application\_gateway\_id) | The ID of the Application Gateway to integrate with the ingress controller of this Kubernetes Cluster. | `string` | `null` | no | | [ingress\_application\_gateway\_name](#input\_ingress\_application\_gateway\_name) | The name of the Application Gateway to be used or created in the Nodepool Resource Group, which in turn will be integrated with the ingress controller of this Kubernetes Cluster. | `string` | `null` | no | diff --git a/main.tf b/main.tf index b8865975..c0604a32 100644 --- a/main.tf +++ b/main.tf @@ -24,7 +24,7 @@ resource "azurerm_kubernetes_cluster" "main" { dns_prefix = var.prefix http_application_routing_enabled = var.http_application_routing_enabled image_cleaner_enabled = var.image_cleaner_enabled - image_cleaner_interval_hours = var.image_cleaner_enabled && var.image_cleaner_interval_hours != null ? var.image_cleaner_interval_hours : null + image_cleaner_interval_hours = var.image_cleaner_interval_hours kubernetes_version = var.kubernetes_version local_account_disabled = var.local_account_disabled node_resource_group = var.node_resource_group diff --git a/variables.tf b/variables.tf index 531e5e34..b6ebbba8 100644 --- a/variables.tf +++ b/variables.tf @@ -470,8 +470,8 @@ variable "image_cleaner_enabled" { variable "image_cleaner_interval_hours" { type = number - description = "(Optional) Specifies the interval in hours when images should be cleaned up." - default = null + description = "(Optional) Specifies the interval in hours when images should be cleaned up. Defaults to `48`." + default = 48 } variable "ingress_application_gateway_enabled" {