{"record":{"id":"5cc9a8b6bab9a8ea","repo":"kubernetes/kops","slug":"unknown-subnet-type-q-for-instancegroup-q","errorCode":null,"errorMessage":"unknown subnet type %q for InstanceGroup %q","messagePattern":"unknown subnet type %q for InstanceGroup %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/template_functions_karpenter.go","lineNumber":503,"sourceCode":"func (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{\n\t\t\tKey:      karpenterOSLabel,\n\t\t\tOperator: \"In\",\n\t\t\tValues:   []string{\"linux\"},\n\t\t},\n\t}\n\n\tvar instanceRequirements *kops.InstanceRequirementsSpec\n\tif ig.Spec.MixedInstancesPolicy != nil {\n\t\tinstanceRequirements = ig.Spec.MixedInstancesPolicy.InstanceRequirements\n\t}\n\n\tif instanceTypes := karpenterInstanceTypes(ig); len(instanceTypes) != 0 {","sourceCodeStart":485,"sourceCodeEnd":521,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/template_functions_karpenter.go#L485-L521","documentation":"karpenterAssociatePublicIP inspects subnets[0].Type and maps subnet types to a public-IP boolean (public/utility => true unless overridden; dualstack/private => false). Any SubnetType outside these known values is not understood and produces this error. It guards against new or corrupted subnet type values reaching the Karpenter template path.","triggerScenarios":"An InstanceGroup used by Karpenter EC2NodeClass rendering has a first subnet whose Type is a value not in {Public, Utility, DualStack, Private} — e.g. an unknown string or a newly introduced SubnetType the current kOps build doesn't know.","commonSituations":"Hand-edited cluster YAML with a misspelled subnet type (e.g. `public` lowercase); running an older kOps binary against a newer cluster spec that uses a new SubnetType enum value.","solutions":["Set the subnet type in the cluster spec to one of: Public, Utility, DualStack, Private.","Fix typos/case in spec.subnets[].type values.","Upgrade (or downgrade to matching) kOps so the binary supports the subnet type in your spec.","Run `kops replace -f cluster.yaml` after correcting the spec, then `kops update cluster`."],"exampleFix":"// before\nsubnets:\n- name: us-east-1a\n  type: publi\n// after\nsubnets:\n- name: us-east-1a\n  type: Public","handlingStrategy":"validation","validationCode":"valid := map[kops.SubnetType]bool{\n    kops.SubnetTypePublic: true,\n    kops.SubnetTypeUtility: true,\n    kops.SubnetTypeDualStack: true,\n    kops.SubnetTypePrivate: true,\n}\nfor _, s := range cluster.Spec.Subnets {\n    if !valid[s.Type] {\n        return fmt.Errorf(\"subnet %q has unsupported type %q\", s.Name, s.Type)\n    }\n}","typeGuard":"func knownSubnetType(t kops.SubnetType) bool {\n    switch t {\n    case kops.SubnetTypePublic, kops.SubnetTypeUtility,\n         kops.SubnetTypeDualStack, kops.SubnetTypePrivate:\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Use only the documented subnet type enum values with exact capitalization.","Match your kOps binary version to the cluster spec's API version.","Avoid hand-editing type fields; edit via `kops edit cluster`.","Diff cluster.yaml against `kops get cluster -o yaml` after manual edits."],"tags":["kops","subnet-type","karpenter","validation"],"backgroundTag":"invalid-enum-value","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"}