AI Features

Creating Worker Nodes

Learn to create worker nodes and view them using Terraform.

Defining worker nodes

We can manage worker node pools (beyond the default one) through the azurerm_kubernetes_cluster_node_pool module. We’ve prepared yet another definition that we can use.

resource "azurerm_kubernetes_cluster_node_pool" "secondary" {
name = "${var.cluster_name}2"
kubernetes_cluster_id = azurerm_kubernetes_cluster.primary.id
vm_size = var.machine_type
enable_auto_scaling = true
max_count = var.max_node_count
min_count = var.min_node_count
}

Explaining the output

  • Line 2: We define the name of the node pool.
  • Line 3: We define the ID of the Kubernetes cluster (kubernetes_cluster_id). Instead of hard-coding it or setting to a value, we’re telling Terraform to use the ID field of the azurerm_kubernetes_cluster.primary resource.
  • Lines 4–7: Further on, we have the size of the VMs (vm_size), whether auto-scaling should be enabled (enable_auto_scaling), and the maximum (
...
Ask