kubernetes/kops · error
found subnets of different types: %v
Error message
found subnets of different types: %v
What it means
Thrown by NodeupModelContext.Init / FindSubnets (pkg/model/context.go:97) when the subnets selected for an InstanceGroup mix subnet Types (e.g. Public and Private, or DualStack vs others). An instance group's subnets must all be the same type because node provisioning (elastic IPs vs internal addresses, routing, etc.) depends on a single consistent subnet type. The message joins the two conflicting types.
Source
Thrown at pkg/model/context.go:97
if clusterSubnet.Name == subnetName {
matches = append(matches, clusterSubnet)
}
}
if len(matches) == 0 {
return nil, fmt.Errorf("subnet not found: %q", subnetName)
}
if len(matches) > 1 {
return nil, fmt.Errorf("found multiple subnets with name: %q", subnetName)
}
subnets = append(subnets, matches[0])
// @step: check the instance is not cross subnet types
switch subnetType {
case "":
subnetType = matches[0].Type
default:
if matches[0].Type != subnetType {
return nil, fmt.Errorf("found subnets of different types: %v", strings.Join([]string{string(subnetType), string(matches[0].Type)}, ","))
}
}
}
return subnets, nil
}
// FindInstanceGroup returns the instance group with the matching Name (or nil if not found)
func (b *KopsModelContext) FindInstanceGroup(name string) *kops.InstanceGroup {
for _, ig := range b.AllInstanceGroups {
if ig.ObjectMeta.Name == name {
return ig
}
}
return nil
}
// FindSubnet returns the subnet with the matching Name (or nil if not found)View on GitHub (pinned to 4c8573c808)
Solutions
- Edit the cluster (kops edit cluster / manifest) so the instance group references only subnets of one type
- If the node should be private, point the IG at the private subnets only; if public/utility, point it at the public subnets only
- Verify each subnet's 'type' field is what you intend (Public/Private/DualStack) and that IG subnet lists were not mixed during a topology migration
- Run 'kops update cluster --target dry-run' after the edit to confirm the model builds cleanly
Example fix
// before (instance group spec) subnets: [us-east-1a, us-east-1a-private] // after subnets: [us-east-1a-private]
Defensive patterns
Strategy: validation
Validate before calling
func validateUniformSubnetTypes(cluster *kops.Cluster, ig *kops.InstanceGroup) error {
byName := map[string]kops.SubnetType{}
for _, s := range cluster.Spec.Subnets { byName[s.Name] = s.Type }
var first kops.SubnetType
for i, name := range ig.Spec.Subnets {
t := byName[name]
if i == 0 { first = t; continue }
if t != first { return fmt.Errorf("IG %q mixes subnet types %v and %v", ig.Name, first, t) }
}
return nil
} Type guard
func uniformSubnetTypes(names []string, byName map[string]kops.SubnetType) bool {
for _, t := range typesOf(names, byName) {
if t != typesOf(names, byName)[0] { return false }
}
return true
} Prevention
- Keep public IGs on utility/public subnets and private IGs on private subnets only
- After a topology migration, grep IG specs for old subnet names
- Run 'kops update cluster --target dry-run' before applying
- Document each subnet's type in your cluster templating tooling
When it happens
Trigger: An InstanceGroup's spec.subnets resolves to subnets whose kops.SubnetType values differ — e.g. an IG listing both a 'utility' (Public) and a 'private' subnet, or a cluster upgraded to a new topology where one subnet's type was changed but the IG still references the old one.
Common situations: Converting a cluster from all-public to private topology and forgetting to update instance groups; renaming subnets so an IG accidentally references both public utility and private subnets; copy-pasted IG definitions across clusters with different topologies.
Related errors
- error instance group cannot span public and private subnets
- error subnets must exist in the cluster
- error parsing Kubernetes version %q: %v
- cannot find subnet %q (declared in instance group %q, not fo
- InstanceGroup #%d did not have a Name
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/d5fd62c68b7f7591.
Report an issue: GitHub.