{"record":{"id":"c7110158b779ddef","repo":"kubernetes/kops","slug":"spotinstancegroup-q-cannot-be-in-subnets-of-diffe","errorCode":null,"errorMessage":"SpotInstanceGroup %q cannot be in subnets of different Type","messagePattern":"SpotInstanceGroup %q cannot be in subnets of different Type","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/model/awsmodel/spotinst.go","lineNumber":741,"sourceCode":"\n\treturn out, nil\n}\n\nfunc (b *SpotInstanceGroupModelBuilder) buildPublicIPOpts(ig *kops.InstanceGroup) (*bool, error) {\n\tsubnetMap := make(map[string]*kops.ClusterSubnetSpec)\n\tfor i := range b.Cluster.Spec.Networking.Subnets {\n\t\tsubnet := &b.Cluster.Spec.Networking.Subnets[i]\n\t\tsubnetMap[subnet.Name] = subnet\n\t}\n\n\tvar subnetType kops.SubnetType\n\tfor _, subnetName := range ig.Spec.Subnets {\n\t\tsubnet := subnetMap[subnetName]\n\t\tif subnet == nil {\n\t\t\treturn nil, fmt.Errorf(\"SpotInstanceGroup %q uses subnet %q that does not exist\", ig.ObjectMeta.Name, subnetName)\n\t\t}\n\t\tif subnetType != \"\" && subnetType != subnet.Type {\n\t\t\treturn nil, fmt.Errorf(\"SpotInstanceGroup %q cannot be in subnets of different Type\", ig.ObjectMeta.Name)\n\t\t}\n\t\tsubnetType = subnet.Type\n\t}\n\n\tvar associatePublicIP bool\n\tswitch subnetType {\n\tcase kops.SubnetTypePublic, kops.SubnetTypeUtility:\n\t\tassociatePublicIP = true\n\t\tif ig.Spec.AssociatePublicIP != nil {\n\t\t\tassociatePublicIP = *ig.Spec.AssociatePublicIP\n\t\t}\n\tcase kops.SubnetTypeDualStack, kops.SubnetTypePrivate:\n\t\tassociatePublicIP = false\n\t\tif ig.Spec.AssociatePublicIP != nil {\n\t\t\tif *ig.Spec.AssociatePublicIP {\n\t\t\t\tklog.Warningf(\"Ignoring AssociatePublicIPAddress=true for private SpotInstanceGroup %q\", ig.ObjectMeta.Name)\n\t\t\t}\n\t\t}","sourceCodeStart":723,"sourceCodeEnd":759,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/model/awsmodel/spotinst.go#L723-L759","documentation":"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.","triggerScenarios":"kops create/update where spec.subnets on a Spotinst IG references both public and private subnets (or DualStack/Private variants of different types).","commonSituations":"Splitting a node group across a public and private subnet during migration, or copy-pasting subnet lists from a cluster with a different topology.","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"],"exampleFix":"// before\nspec:\n  subnets: [public-a, private-b]\n// after (split into two IGs)\nspec:\n  subnets: [private-a, private-b]","handlingStrategy":"validation","validationCode":"types := map[kops.SubnetType]bool{}\nfor _, igSubnet := range ig.Spec.Subnets {\n  for _, s := range cluster.Spec.Subnets {\n    if s.Name == igSubnet { types[s.Type] = true }\n  }\n}\nif len(types) > 1 {\n  return fmt.Errorf(\"IG %s spans subnets of different types\", ig.Name)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["aws","spotinst","subnets","network"],"backgroundTag":"mixed-subnet-types","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}