» azurerm_kubernetes_cluster_node_pool

Manages a Node Pool within a Kubernetes Cluster

» Example Usage

resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "West Europe"
}

resource "azurerm_kubernetes_cluster" "example" {
  name                = "example-aks1"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  dns_prefix          = "exampleaks1"

  default_node_pool {
    name       = "default"
    node_count = 1
    vm_size    = "Standard_D2_v2"
  }

  service_principal {
    client_id     = "00000000-0000-0000-0000-000000000000"
    client_secret = "00000000000000000000000000000000"
  }
}

resource "azurerm_kubernetes_cluster_node_pool" "example" {
  name                  = "internal"
  kubernetes_cluster_id = azurerm_kubernetes_cluster.example.id
  vm_size               = "Standard_DS2_v2"
  node_count            = 1

  tags = {
    Environment = "Production"
  }
}

» Argument Reference

The following arguments are supported:

  • name - (Required) The name of the Node Pool which should be created within the Kubernetes Cluster. Changing this forces a new resource to be created.
  • kubernetes_cluster_id - (Required) The ID of the Kubernetes Cluster where this Node Pool should exist. Changing this forces a new resource to be created.

  • vm_size - (Required) The SKU which should be used for the Virtual Machines used in this Node Pool. Changing this forces a new resource to be created.


  • enable_node_public_ip - (Optional) Should each node have a Public IP Address? Defaults to false.

  • max_pods - (Optional) The maximum number of pods that can run on each agent. Changing this forces a new resource to be created.

  • node_labels - (Optional) A map of Kubernetes labels which should be applied to nodes in this Node Pool.

  • node_taints - (Optional) A list of Kubernetes taints which should be applied to nodes in the agent pool (e.g key=value:NoSchedule).

  • os_disk_size_gb - (Optional) The Agent Operating System disk size in GB. Changing this forces a new resource to be created.

  • os_type - (Optional) The Operating System which should be used for this Node Pool. Changing this forces a new resource to be created. Possible values are Linux and Windows. Defaults to Linux.

  • tags - (Optional) A mapping of tags to assign to the resource.

  • vnet_subnet_id - (Optional) The ID of the Subnet where this Node Pool should exist.


When enable_auto_scaling is set to true the following fields are applicable:

  • max_count - (Required) The maximum number of nodes which should exist within this Node Pool. Valid values are between 1 and 100 and must be greater than or equal to min_count.

  • min_count - (Required) The minimum number of nodes which should exist within this Node Pool. Valid values are between 1 and 100 and must be less than or equal to max_count.

  • node_count - (Optional) The initial number of nodes which should exist within this Node Pool. Valid values are between 1 and 100 and must be a value in the range min_count - max_count.

When enable_auto_scaling is set to false the following fields are applicable:

  • node_count - (Required) The number of nodes which should exist within this Node Pool. Valid values are between 1 and 100.

» Attributes Reference

The following attributes are exported:

  • id - The ID of the Kubernetes Cluster Node Pool.

» Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 60 minutes) Used when creating the Kubernetes Cluster Node Pool.
  • update - (Defaults to 60 minutes) Used when updating the Kubernetes Cluster Node Pool.
  • read - (Defaults to 5 minutes) Used when retrieving the Kubernetes Cluster Node Pool.
  • delete - (Defaults to 60 minutes) Used when deleting the Kubernetes Cluster Node Pool.

» Import

Kubernetes Cluster Node Pools can be imported using the resource id, e.g.

terraform import azurerm_kubernetes_cluster_node_pool.pool1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.ContainerService/managedClusters/cluster1/agentPools/pool1