Created
July 28, 2021 12:40
-
-
Save enriquecatala/b4663aca53a630836ac82dfa90e785db to your computer and use it in GitHub Desktop.
Terraform AKS Spot instance node pool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Create Linux Azure AKS Spot instance Node Pool | |
| # Required extension: | |
| # az extension add --name aks-preview | |
| # | |
| resource "azurerm_kubernetes_cluster_node_pool" "nodepool_cpu_spot" { | |
| #availability_zones = [1, 2, 3] | |
| enable_auto_scaling = true | |
| kubernetes_cluster_id = azurerm_kubernetes_cluster.aks_cluster.id | |
| max_count = 3 | |
| min_count = 1 | |
| mode = "User" | |
| name = "cpuspot" | |
| #orchestrator_version = data.azurerm_kubernetes_service_versions.current.latest_version | |
| orchestrator_version =azurerm_kubernetes_cluster.aks_cluster.kubernetes_version | |
| os_disk_size_gb = 128 | |
| os_type = "Linux" # Default is Linux, we can change to Windows | |
| vm_size = "standard_d16s_v4" # "Standard_NC6_Promo" Promo is not available for Spot instances | |
| priority = "Spot" # Default is Regular, we can change to Spot with additional settings like eviction_policy, spot_max_price, node_labels and node_taints | |
| spot_max_price = -1 # Set to -1 to disable the max_price (not eviction based on price) | |
| eviction_policy = "Delete" # Deallocate will count against your quota and there is no guarantee the node can be realocated | |
| vnet_subnet_id = azurerm_subnet.aks-subnet.id | |
| node_taints = ["kubernetes.azure.com/scalesetpriority=spot:NoSchedule"] | |
| node_labels = { | |
| "nodepool-type" = "user" | |
| "environment" = var.environment | |
| "nodepoolos" = "linux" | |
| "sku" = "cpu" | |
| "kubernetes.azure.com/scalesetpriority" = "spot" | |
| } | |
| tags = { | |
| "nodepool-type" = "user" | |
| "environment" = var.environment | |
| "nodepoolos" = "linux" | |
| "sku" = "cpu" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment