Skip to content

Commit

Permalink
Support for creating nodepools from snapshots (Azure#442)
Browse files Browse the repository at this point in the history
* Support for creating nodepools from snapshots

Fixes Azure#436
  • Loading branch information
zioproto authored and skolobov committed Oct 29, 2023
1 parent 5519ce6 commit 9ce3a11
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ The following sections are generated by [terraform-docs](https://github.com/terr
|---------------------------------------------------------------------------|------------------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
| <a name="requirement_azapi"></a> [azapi](#requirement\_azapi) | >= 1.4.0, < 2.0 |
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | >= 3.51.0, < 4.0 |
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | >= 3.69.0, < 4.0 |
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 3.0 |
| <a name="requirement_tls"></a> [tls](#requirement\_tls) | >= 3.1 |

Expand All @@ -220,7 +220,7 @@ The following sections are generated by [terraform-docs](https://github.com/terr
| Name | Version |
|---------------------------------------------------------------|------------------|
| <a name="provider_azapi"></a> [azapi](#provider\_azapi) | >= 1.4.0, < 2.0 |
| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | >= 3.51.0, < 4.0 |
| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | >= 3.69.0, < 4.0 |
| <a name="provider_null"></a> [null](#provider\_null) | >= 3.0 |
| <a name="provider_tls"></a> [tls](#provider\_tls) | >= 3.1 |

Expand Down
3 changes: 3 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ resource "azurerm_kubernetes_cluster" "main" {
ultra_ssd_enabled = var.ultra_ssd_enabled
vnet_subnet_id = var.vnet_subnet_id
zones = var.agents_availability_zones
snapshot_id = var.snapshot_id

dynamic "kubelet_config" {
for_each = var.agents_pool_kubelet_configs
Expand Down Expand Up @@ -174,6 +175,7 @@ resource "azurerm_kubernetes_cluster" "main" {
ultra_ssd_enabled = var.ultra_ssd_enabled
vnet_subnet_id = var.vnet_subnet_id
zones = var.agents_availability_zones
snapshot_id = var.snapshot_id

dynamic "kubelet_config" {
for_each = var.agents_pool_kubelet_configs
Expand Down Expand Up @@ -597,6 +599,7 @@ resource "azurerm_kubernetes_cluster_node_pool" "node_pool" {
vnet_subnet_id = each.value.vnet_subnet_id
workload_runtime = each.value.workload_runtime
zones = each.value.zones
snapshot_id = each.value.snapshot_id

dynamic "kubelet_config" {
for_each = each.value.kubelet_config == null ? [] : ["kubelet_config"]
Expand Down
8 changes: 8 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,7 @@ variable "node_pools" {
proximity_placement_group_id = optional(string)
spot_max_price = optional(number)
scale_down_mode = optional(string, "Delete")
snapshot_id = optional(string)
ultra_ssd_enabled = optional(bool)
vnet_subnet_id = optional(string)
upgrade_settings = optional(object({
Expand Down Expand Up @@ -942,6 +943,7 @@ variable "node_pools" {
proximity_placement_group_id = (Optional) The ID of the Proximity Placement Group where the Virtual Machine Scale Set that powers this Node Pool will be placed. Changing this forces a new resource to be created. When setting `priority` to Spot - you must configure an `eviction_policy`, `spot_max_price` and add the applicable `node_labels` and `node_taints` [as per the Azure Documentation](https://docs.microsoft.com/azure/aks/spot-node-pool).
spot_max_price = (Optional) The maximum price you're willing to pay in USD per Virtual Machine. Valid values are `-1` (the current on-demand price for a Virtual Machine) or a positive value with up to five decimal places. Changing this forces a new resource to be created. This field can only be configured when `priority` is set to `Spot`.
scale_down_mode = (Optional) Specifies how the node pool should deal with scaled-down nodes. Allowed values are `Delete` and `Deallocate`. Defaults to `Delete`.
snapshot_id = (Optional) The ID of the Snapshot which should be used to create this Node Pool. Changing this forces a new resource to be created.
ultra_ssd_enabled = (Optional) Used to specify whether the UltraSSD is enabled in the Node Pool. Defaults to `false`. See [the documentation](https://docs.microsoft.com/azure/aks/use-ultra-disks) for more information. Changing this forces a new resource to be created.
vnet_subnet_id = (Optional) The ID of the Subnet where this Node Pool should exist. Changing this forces a new resource to be created. A route table must be configured on this Subnet.
upgrade_settings = optional(object({
Expand Down Expand Up @@ -1138,6 +1140,12 @@ variable "sku_tier" {
}
}

variable "snapshot_id" {
type = string
default = null
description = "(Optional) The ID of the Snapshot which should be used to create this default Node Pool. `temporary_name_for_rotation` must be specified when changing this property."
}

variable "storage_profile_blob_driver_enabled" {
type = bool
default = false
Expand Down
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ terraform {
}
azurerm = {
source = "hashicorp/azurerm"
version = ">= 3.51.0, < 4.0"
version = ">= 3.69.0, < 4.0"
}
null = {
source = "hashicorp/null"
Expand Down

0 comments on commit 9ce3a11

Please sign in to comment.