» azurerm_kubernetes_cluster_node_pool

Manages a Node Pool within a Kubernetes Cluster

» Example Usage

This example provisions a basic Kubernetes Node Pool. Other examples of the azurerm_kubernetes_cluster_node_pool resource can be found in the ./examples/kubernetes directory within the Github Repository

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.

  • eviction_policy - (Optional) The Eviction Policy which should be used for Virtual Machines within the Virtual Machine Scale Set powering this Node Pool. Possible values are Deallocate and Delete. Changing this forces a new resource to be created.

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

  • mode - (Optional) Should this Node Pool be used for System or User resources? Possible values are System and User. Defaults to User.

  • node_labels - (Optional) A map of Kubernetes labels which should be applied to nodes in this Node Pool. Changing this forces a new resource to be created.

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

  • orchestrator_version - (Optional) Version of Kubernetes used for the Agents. If not specified, the latest recommended version will be used at provisioning time (but won't auto-upgrade)

  • 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.

  • priority - (Optional) The Priority for Virtual Machines within the Virtual Machine Scale Set that powers this Node Pool. Possible values are Regular and Spot. Defaults to Regular. Changing this forces a new resource to be created.

  • 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.
  • 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.

If enable_auto_scaling is set to true, then the following fields can also be configured:

  • 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.

If enable_auto_scaling is set to false, then the following fields can also be configured:

  • 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