kubernetes/kops · error
SpotInstanceGroup %q cannot be in subnets of different Type
Error message
SpotInstanceGroup %q cannot be in subnets of different Type
What it means
Raised by buildPublicIPOpts when the SpotInstanceGroup's subnets include more than one distinct kops.SubnetType (e.g. mixing Public and Private). Since the builder derives a single public-IP policy from the subnet type, mixed types are ambiguous and rejected.
Source
Thrown at pkg/model/awsmodel/spotinst.go:741
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 {
klog.Warningf("Ignoring AssociatePublicIPAddress=true for private SpotInstanceGroup %q", ig.ObjectMeta.Name)
}
}View on GitHub (pinned to 4c8573c808)
Solutions
- Ensure all subnets in spec.subnets have the same type in the cluster spec
- Split the instance group into one per subnet type
- Run kops get cluster to inspect each subnet's type
- Re-run kops update --yes
Example fix
// before spec: subnets: [public-a, private-b] // after (split into two IGs) spec: subnets: [private-a, private-b]
Defensive patterns
Strategy: validation
Validate before calling
types := map[kops.SubnetType]bool{}
for _, igSubnet := range ig.Spec.Subnets {
for _, s := range cluster.Spec.Subnets {
if s.Name == igSubnet { types[s.Type] = true }
}
}
if len(types) > 1 {
return fmt.Errorf("IG %s spans subnets of different types", ig.Name)
} Prevention
- Assign each instance group subnets of a single type
- Split mixed workloads into separate IGs per subnet type
- Review subnet types when migrating clusters between topologies
When it happens
Trigger: kops create/update where spec.subnets on a Spotinst IG references both public and private subnets (or DualStack/Private variants of different types).
Common situations: Splitting a node group across a public and private subnet during migration, or copy-pasting subnet lists from a cluster with a different topology.
Related errors
- could not determine any subnets for SpotInstanceGroup %q; su
- SpotInstanceGroup %q uses subnet %q that does not exist
- error building public ip options: %v
- error building subnets: %v
- unknown subnet type %q
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/c7110158b779ddef.
Report an issue: GitHub.