{"record":{"id":"dfdb9ed56d8183b4","repo":"kubernetes/kops","slug":"could-not-determine-any-subnets-for-instancegroup-dfdb9e","errorCode":null,"errorMessage":"could not determine any subnets for InstanceGroup %q; subnets was %s","messagePattern":"could not determine any subnets for InstanceGroup %q; subnets was (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/template_functions_karpenter.go","lineNumber":491,"sourceCode":"\t}\n\n\ttokens := strings.SplitN(image, \"/\", 2)\n\tif len(tokens) == 1 {\n\t\treturn []karpenterAMITerm{{Name: image, Owner: \"self\"}}, nil\n\t}\n\tif tokens[0] == \"\" || tokens[1] == \"\" {\n\t\treturn nil, fmt.Errorf(\"image %q must be ami-*, ssm:<parameter>, <name>, or <owner>/<name>\", image)\n\t}\n\treturn []karpenterAMITerm{{Owner: awsup.ResolveImageOwnerAlias(tokens[0]), Name: tokens[1]}}, nil\n}\n\nfunc (tf *TemplateFunctions) karpenterAssociatePublicIP(ig *kops.InstanceGroup) (*bool, error) {\n\tsubnets, err := tf.GatherSubnets(ig)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(subnets) == 0 {\n\t\treturn nil, fmt.Errorf(\"could not determine any subnets for InstanceGroup %q; subnets was %s\", ig.Name, ig.Spec.Subnets)\n\t}\n\n\tswitch subnets[0].Type {\n\tcase kops.SubnetTypePublic, kops.SubnetTypeUtility:\n\t\tif ig.Spec.AssociatePublicIP != nil {\n\t\t\treturn ig.Spec.AssociatePublicIP, nil\n\t\t}\n\t\treturn new(true), nil\n\tcase kops.SubnetTypeDualStack, kops.SubnetTypePrivate:\n\t\treturn new(false), nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unknown subnet type %q for InstanceGroup %q\", subnets[0].Type, ig.Name)\n\t}\n}\n\nfunc (tf *TemplateFunctions) karpenterRequirements(ig *kops.InstanceGroup) []karpenterRequirement {\n\trequirements := []karpenterRequirement{\n\t\t{","sourceCodeStart":473,"sourceCodeEnd":509,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/template_functions_karpenter.go#L473-L509","documentation":"karpenterAssociatePublicIP resolves the subnets of a Karpenter-managed InstanceGroup to decide whether instances get a public IP. It calls GatherSubnets; when the result is empty it cannot classify the InstanceGroup, so it fails with this error. The error message includes the InstanceGroup name and its raw Spec.Subnets list for diagnosis.","triggerScenarios":"kOps apply/build of a cluster containing a Karpenter EC2NodeClass whose associated InstanceGroup has an empty (or effectively unresolvable) Spec.Subnets list, or subnets that GatherSubnets cannot match against the cluster's defined subnets.","commonSituations":"NodeTemplates/InstanceGroups created without a `subnets` field; subnets referencing names/zones not present in the cluster spec; Karpenter generated IGs that bypass normal subnet assignment; partial cluster configs migrated between kOps versions.","solutions":["Set spec.subnets on the InstanceGroup to valid cluster subnet names (e.g. `subnets: [us-east-1a]`) and re-run kops update.","Verify the listed subnet names exist in the cluster spec (cluster.spec.subnets) and match exactly (name/zone).","If the IG is auto-generated by Karpenter integration, ensure the cluster spec subnets are populated before applying.","Run `kops get instancegroups` / `kops get cluster -o yaml` to confirm subnet wiring."],"exampleFix":"// before\nspec:\n  subnets: []\n// after\nspec:\n  subnets:\n  - us-east-1a","handlingStrategy":"validation","validationCode":"igName := ig.Name\nif len(ig.Spec.Subnets) == 0 {\n    return fmt.Errorf(\"instance group %q has no subnets; set spec.subnets to cluster subnet names\", igName)\n}","typeGuard":"func hasSubnets(ig *kops.InstanceGroup) bool {\n    return ig != nil && len(ig.Spec.Subnets) > 0\n}","tryCatchPattern":null,"preventionTips":["Always set spec.subnets on every InstanceGroup, including Karpenter-managed ones.","Validate that IG subnet names match cluster.spec.subnets names before `kops update`.","Run `kops validate cluster` after config edits and before applying.","Lint cluster YAML against the kops API schema for your kOps version."],"tags":["kops","subnets","karpenter","config"],"backgroundTag":"no-subnets-configured","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"}