Skip to content

Commit 6ae5719

Browse files
authored
Support for creating nodepools from snapshots (#442)
* Support for creating nodepools from snapshots Fixes #436
1 parent f884672 commit 6ae5719

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ The following sections are generated by [terraform-docs](https://github.com/terr
211211
|---------------------------------------------------------------------------|------------------|
212212
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
213213
| <a name="requirement_azapi"></a> [azapi](#requirement\_azapi) | >= 1.4.0, < 2.0 |
214-
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | >= 3.51.0, < 4.0 |
214+
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | >= 3.69.0, < 4.0 |
215215
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 3.0 |
216216
| <a name="requirement_tls"></a> [tls](#requirement\_tls) | >= 3.1 |
217217

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

main.tf

+3
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ resource "azurerm_kubernetes_cluster" "main" {
7575
ultra_ssd_enabled = var.ultra_ssd_enabled
7676
vnet_subnet_id = var.vnet_subnet_id
7777
zones = var.agents_availability_zones
78+
snapshot_id = var.snapshot_id
7879

7980
dynamic "kubelet_config" {
8081
for_each = var.agents_pool_kubelet_configs
@@ -174,6 +175,7 @@ resource "azurerm_kubernetes_cluster" "main" {
174175
ultra_ssd_enabled = var.ultra_ssd_enabled
175176
vnet_subnet_id = var.vnet_subnet_id
176177
zones = var.agents_availability_zones
178+
snapshot_id = var.snapshot_id
177179

178180
dynamic "kubelet_config" {
179181
for_each = var.agents_pool_kubelet_configs
@@ -597,6 +599,7 @@ resource "azurerm_kubernetes_cluster_node_pool" "node_pool" {
597599
vnet_subnet_id = each.value.vnet_subnet_id
598600
workload_runtime = each.value.workload_runtime
599601
zones = each.value.zones
602+
snapshot_id = each.value.snapshot_id
600603

601604
dynamic "kubelet_config" {
602605
for_each = each.value.kubelet_config == null ? [] : ["kubelet_config"]

variables.tf

+8
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,7 @@ variable "node_pools" {
845845
proximity_placement_group_id = optional(string)
846846
spot_max_price = optional(number)
847847
scale_down_mode = optional(string, "Delete")
848+
snapshot_id = optional(string)
848849
ultra_ssd_enabled = optional(bool)
849850
vnet_subnet_id = optional(string)
850851
upgrade_settings = optional(object({
@@ -942,6 +943,7 @@ variable "node_pools" {
942943
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).
943944
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`.
944945
scale_down_mode = (Optional) Specifies how the node pool should deal with scaled-down nodes. Allowed values are `Delete` and `Deallocate`. Defaults to `Delete`.
946+
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.
945947
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.
946948
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.
947949
upgrade_settings = optional(object({
@@ -1138,6 +1140,12 @@ variable "sku_tier" {
11381140
}
11391141
}
11401142

1143+
variable "snapshot_id" {
1144+
type = string
1145+
default = null
1146+
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."
1147+
}
1148+
11411149
variable "storage_profile_blob_driver_enabled" {
11421150
type = bool
11431151
default = false

versions.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ terraform {
88
}
99
azurerm = {
1010
source = "hashicorp/azurerm"
11-
version = ">= 3.51.0, < 4.0"
11+
version = ">= 3.69.0, < 4.0"
1212
}
1313
null = {
1414
source = "hashicorp/null"

0 commit comments

Comments
 (0)