kubernetes/kops · error

SpotInstanceGroup %q uses subnet %q that does not exist

Error message

SpotInstanceGroup %q uses subnet %q that does not exist

What it means

Raised by buildPublicIPOpts when a subnet name listed in the SpotInstanceGroup spec cannot be found in the cluster subnet map. kops refuses to guess, because public-IP policy depends on the subnet's type. The message names the IG and the missing subnet.

Source

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

	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
	for _, subnetName := range ig.Spec.Subnets {
		subnet := subnetMap[subnetName]
		if subnet == nil {
			return nil, fmt.Errorf("SpotInstanceGroup %q uses subnet %q that does not exist", ig.ObjectMeta.Name, subnetName)
		}
		if subnetType != "" && subnetType != subnet.Type {
			return nil, fmt.Errorf("SpotInstanceGroup %q cannot be in subnets of different Type", ig.ObjectMeta.Name)
		}
		subnetType = subnet.Type
	}

	var associatePublicIP bool
	switch subnetType {
	case kops.SubnetTypePublic, kops.SubnetTypeUtility:
		associatePublicIP = true
		if ig.Spec.AssociatePublicIP != nil {
			associatePublicIP = *ig.Spec.AssociatePublicIP
		}
	case kops.SubnetTypeDualStack, kops.SubnetTypePrivate:
		associatePublicIP = false
		if ig.Spec.AssociatePublicIP != nil {
			if *ig.Spec.AssociatePublicIP {

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Run kops get cluster -o yaml and copy the exact subnet names into the IG spec
  2. Fix the typo in spec.subnets (names are case-sensitive)
  3. If the subnet was removed from the cluster, remove it from the IG too
  4. Re-run kops update --yes

Example fix

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

Strategy: validation

Validate before calling

names := map[string]*kops.Subnet{}
for i := range cluster.Spec.Subnets { names[cluster.Spec.Subnets[i].Name] = &cluster.Spec.Subnets[i] }
for _, n := range ig.Spec.Subnets {
  if names[n] == nil {
    return fmt.Errorf("subnet %q referenced by IG %q does not exist", n, ig.Name)
  }
}

Prevention

When it happens

Trigger: kops create/update where spec.subnets on the Spotinst instance group contains a name absent from the cluster spec's subnets list (case-sensitive exact match).

Common situations: Typos in subnet names, renamed subnets in the cluster spec without updating IGs, or an IG moved between clusters with different subnet naming.

Related errors


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