kubernetes/kops · error

could not determine any subnets for SpotInstanceGroup %q; su

Error message

could not determine any subnets for SpotInstanceGroup %q; subnets was %s

What it means

Raised by buildSubnets when GatherSubnets returns zero subnets for a SpotInstanceGroup: kops cannot map the instance group to any cluster subnet, so no launch spec can be built. The message includes the IG name and its configured subnets string for diagnosis.

Source

Thrown at pkg/model/awsmodel/spotinst.go:716

			Lifecycle: b.SecurityLifecycle,
			ID:        new(id),
			Name:      new(id),
			Shared:    new(true),
		}
		c.EnsureTask(sg)
		securityGroups = append(securityGroups, sg)
	}

	return securityGroups, nil
}

func (b *SpotInstanceGroupModelBuilder) buildSubnets(ig *kops.InstanceGroup) ([]*awstasks.Subnet, error) {
	subnets, err := b.GatherSubnets(ig)
	if err != nil {
		return nil, err
	}
	if len(subnets) == 0 {
		return nil, fmt.Errorf("could not determine any subnets for SpotInstanceGroup %q; subnets was %s", ig.ObjectMeta.Name, ig.Spec.Subnets)
	}

	out := make([]*awstasks.Subnet, len(subnets))
	for i, subnet := range subnets {
		out[i] = b.LinkToSubnet(subnet)
	}

	return out, nil
}

func (b *SpotInstanceGroupModelBuilder) buildPublicIPOpts(ig *kops.InstanceGroup) (*bool, error) {
	subnetMap := make(map[string]*kops.ClusterSubnetSpec)
	for i := range b.Cluster.Spec.Networking.Subnets {
		subnet := &b.Cluster.Spec.Networking.Subnets[i]
		subnetMap[subnet.Name] = subnet
	}

	var subnetType kops.SubnetType

View on GitHub (pinned to 4c8573c808)

Solutions

  1. List spec.subnets names on the IG and match them exactly against the cluster spec subnets
  2. Add at least one valid subnet name to spec.subnets
  3. Run kops get cluster to confirm the cluster's subnet names
  4. Re-run kops update --yes

Example fix

// before
spec:
  subnets: [old-name]
// after
spec:
  subnets: [private-a]
Defensive patterns

Strategy: validation

Validate before calling

if len(ig.Spec.Subnets) == 0 {
  return fmt.Errorf("IG %s must list at least one cluster subnet", ig.ObjectMeta.Name)
}
valid := map[string]bool{}
for _, s := range cluster.Spec.Subnets { valid[s.Name] = true }
for _, n := range ig.Spec.Subnets {
  if !valid[n] { return fmt.Errorf("IG %s: subnet %q not found in cluster", ig.ObjectMeta.Name, n) }
}

Prevention

When it happens

Trigger: kops create/update where a Spotinst instance group has an empty spec.subnets, or names that match no subnet in the cluster spec (GatherSubnets filters out unknown names).

Common situations: Copy-pasting an instance group between clusters with different subnet names, deleting subnets from the cluster spec but leaving them on the IG, or leaving spec.subnets empty.

Related errors


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