{"record":{"id":"2d940160a0c137d1","repo":"kubernetes/kops","slug":"subnet-q-had-unknown-type-q","errorCode":null,"errorMessage":"subnet %q had unknown type %q","messagePattern":"subnet %q had unknown type %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/model/awsmodel/api_loadbalancer.go","lineNumber":102,"sourceCode":"\t} else {\n\t\t// Compute the subnets - only one per zone, and then break ties based on chooseBestSubnetForELB\n\t\tsubnetsByZone := make(map[string][]*kops.ClusterSubnetSpec)\n\t\tfor i := range b.Cluster.Spec.Networking.Subnets {\n\t\t\tsubnet := &b.Cluster.Spec.Networking.Subnets[i]\n\n\t\t\tswitch subnet.Type {\n\t\t\tcase kops.SubnetTypePublic, kops.SubnetTypeUtility:\n\t\t\t\tif lbSpec.Type != kops.LoadBalancerTypePublic {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\tcase kops.SubnetTypeDualStack, kops.SubnetTypePrivate:\n\t\t\t\tif lbSpec.Type != kops.LoadBalancerTypeInternal {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\treturn fmt.Errorf(\"subnet %q had unknown type %q\", subnet.Name, subnet.Type)\n\t\t\t}\n\n\t\t\tsubnetsByZone[subnet.Zone] = append(subnetsByZone[subnet.Zone], subnet)\n\t\t}\n\n\t\tfor zone, subnets := range subnetsByZone {\n\t\t\tsubnet := b.chooseBestSubnetForELB(zone, subnets)\n\n\t\t\tnlbSubnetMappings = append(nlbSubnetMappings, &awstasks.SubnetMapping{Subnet: b.LinkToSubnet(subnet)})\n\t\t}\n\t}\n\n\tvar nlb *awstasks.NetworkLoadBalancer\n\t{\n\t\tvar nlbListeners []*awstasks.NetworkLoadBalancerListener\n\n\t\tif lbSpec.SSLCertificate == \"\" {\n\t\t\tlistener443 := &awstasks.NetworkLoadBalancerListener{","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/model/awsmodel/api_loadbalancer.go#L84-L120","documentation":"When kOps auto-selects subnets for the API load balancer, it classifies each cluster subnet type (Public, Utility, DualStack, Private) to decide eligibility. This error fires when a subnet in spec.networking.subnets has a type outside the known enum, so the builder cannot determine whether it can back the load balancer.","triggerScenarios":"Running kops update/create cluster on AWS with api.loadBalancer configured and no explicit api.loadBalancer.subnets, where a subnet's spec.networking.subnets[].type is an unrecognized string (typo like \"privte\", \"Public \" or a removed/renamed type value).","commonSituations":"Hand-edited cluster specs, migration from older kOps versions where subnet type values changed, or copy-pasted specs from non-AWS examples with different subnet type naming.","solutions":["Set each subnet type to a valid value: Public, Utility, Private, or DualStack","Run `kops get cluster -o yaml`, fix subnet types, and `kops replace -f` the spec","Alternatively set api.loadBalancer.subnets explicitly so auto-selection (and its type check) is bypassed"],"exampleFix":"# before\nsubnets:\n- name: us-east-1a\n  type: privte\n  zone: us-east-1a\n# after\nsubnets:\n- name: us-east-1a\n  type: Private\n  zone: us-east-1a","handlingStrategy":"validation","validationCode":"valid := map[kops.SubnetType]bool{\n    kops.SubnetTypePublic: true,\n    kops.SubnetTypeUtility: true,\n    kops.SubnetTypePrivate: true,\n    kops.SubnetTypeDualStack: true,\n}\nfor _, s := range cluster.Spec.Networking.Subnets {\n    if !valid[s.Type] {\n        return fmt.Errorf(\"subnet %q has invalid 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.SubnetTypePrivate, kops.SubnetTypeDualStack:\n        return true\n    }\n    return false\n}","tryCatchPattern":"if err := kopsUpdateCluster(cluster); err != nil {\n    if strings.Contains(err.Error(), \"had unknown type\") {\n        // correct spec.networking.subnets[].type and retry\n    }\n    return err\n}","preventionTips":["Restrict subnet types to Public, Utility, Private, DualStack","Set api.loadBalancer.subnets explicitly to control which subnets are checked","Validate the cluster spec with `kops validate` or the kops API types before applying"],"tags":["aws","kops","subnet","cluster-spec"],"backgroundTag":"invalid-subnet-type","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"}