kubernetes/kops · error

unable to infer any Subnets for InstanceGroup %s

Error message

unable to infer any Subnets for InstanceGroup %s 

What it means

After the API-server-only IPv6 fallback tries to infer subnets from the cluster spec, if spec.subnets is still empty kOps cannot determine where to place the InstanceGroup's machines and returns this error.

Source

Thrown at upup/pkg/fi/cloudup/populate_instancegroup_spec.go:202

		if len(ig.Spec.Subnets) == 0 {
			for _, subnet := range cluster.Spec.Networking.Subnets {
				if subnet.Type != kops.SubnetTypeDualStack && subnet.Type != kops.SubnetTypeUtility {
					ig.Spec.Subnets = append(ig.Spec.Subnets, subnet.Name)
				}
			}
		}

		if len(ig.Spec.Subnets) == 0 {
			for _, subnet := range cluster.Spec.Networking.Subnets {
				if subnet.Type != kops.SubnetTypeUtility {
					ig.Spec.Subnets = append(ig.Spec.Subnets, subnet.Name)
				}
			}
		}
	}

	if len(ig.Spec.Subnets) == 0 {
		return nil, fmt.Errorf("unable to infer any Subnets for InstanceGroup %s ", ig.ObjectMeta.Name)
	}

	hasGPU := false
	clusterNvidia := cluster.Spec.Containerd != nil && cluster.Spec.Containerd.NvidiaGPU != nil && fi.ValueOf(cluster.Spec.Containerd.NvidiaGPU.Enabled)
	igNvidia := ig.Spec.Containerd != nil && ig.Spec.Containerd.NvidiaGPU != nil && fi.ValueOf(ig.Spec.Containerd.NvidiaGPU.Enabled)

	switch cluster.GetCloudProvider() {
	case kops.CloudProviderAWS:
		if clusterNvidia || igNvidia {
			mt, err := awsup.GetMachineTypeInfo(cloud.(awsup.AWSCloud), ec2types.InstanceType(ig.Spec.MachineType))
			if err != nil {
				return ig, fmt.Errorf("error looking up machine type info: %v", err)
			}
			hasGPU = mt.GPU
		}
	case kops.CloudProviderOpenstack:
		if igNvidia {
			hasGPU = true

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Set spec.subnets explicitly on the InstanceGroup
  2. For IPv6-only clusters, add public (non-private/utility) subnets to cluster.spec.networking.subnets so inference can succeed
  3. Recreate the group with --subnet: `kops create instancegroup nodes --subnet us-east-1a`

Example fix

// before
spec:
  role: Node
// after
spec:
  role: Node
  subnets:
  - us-east-1a
  - us-east-1b
Defensive patterns

Strategy: validation

Validate before calling

// Require subnets on every instance group before populating
for _, ig := range instanceGroups {
    if len(ig.Spec.Subnets) == 0 {
        return fmt.Errorf("instance group %s: set spec.subnets", ig.ObjectMeta.Name)
    }
}

Prevention

When it happens

Trigger: Any InstanceGroup (node, bastion, apiserver-only) with empty spec.subnets where inference fails: the cluster has no non-private/non-utility subnets for the IPv6 fallback, or the group isn't eligible for inference at all.

Common situations: Node InstanceGroups created without --subnet on clusters where defaults can't be inferred; IPv6-only clusters whose only subnets are private/utility; bastion groups defined without subnets.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/3154d599dd2828d7. Report an issue: GitHub.