Skip to content

Autoscaler nodes assigned to wrong subnet in shared networks #321

@sergeyv5577-hero

Description

@sergeyv5577-hero

Description

When a shared Hetzner network has multiple subnets, the Hetzner Cloud API assigns new servers to the last created subnet by default. The module passes only HCLOUD_NETWORK (network ID) to the autoscaler helm chart without specifying a subnet, so autoscaler nodes land in whatever subnet was created last — not the cluster's dedicated hcloud_network_subnet.autoscaler subnet.

With private-only cluster access, the autoscaler node can't communicate with the rest of the cluster.

The upstream cluster-autoscaler already supports subnetIPRange in nodeConfigs since helm chart 9.52.0 (kubernetes/autoscaler#8570), but the module doesn't pass it — autoscaler.tf only sets cloudInit, labels, and taints in nodeConfigs.

PR #226 addresses this but has been stale since Nov 2025. Its upstream dependency merged Oct 2025.

Expected Behavior

Autoscaler nodes should be assigned to the cluster's dedicated autoscaler subnet (hcloud_network_subnet.autoscaler).

Actual Behavior

Autoscaler nodes are assigned to whichever subnet was created last in the shared network. E.g. if a 10.111.0.0/24 subnet exists and was created after the cluster subnet, autoscaler nodes land there instead of the cluster's 10.3.64.0/19 range.

Minimal Module Configuration

module "kubernetes" {
  source  = "hcloud-k8s/kubernetes/hcloud"
  version = "3.21.3"

  hcloud_network_id          = data.terraform_remote_state.shared.outputs.network_id  # shared network with multiple subnets
  network_node_ipv4_cidr     = "10.3.64.0/19"

  cluster_autoscaler_nodepools = [
    {
      name     = "autoscaler"
      type     = "cpx41"
      location = "fsn1"
      max      = 5
    }
  ]
}

Relevant Output

$ talosctl get members
NODE                                    ADDRESSES
cluster-autoscaler-abc123   ["10.111.0.2","x.x.x.x"]   # wrong: landed in 10.111.0.0/24 (last created subnet)
cluster-control-1           ["10.3.64.1","x.x.x.x"]   # correct: cluster subnet
cluster-worker-1            ["10.3.65.1","x.x.x.x"]   # correct: cluster subnet

Confirmation

  • I checked existing issues, discussions, and the web for similar problems

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions