{"record":{"id":"ad25e95e939719e8","repo":"kubernetes/kops","slug":"configuration-must-include-subnets","errorCode":null,"errorMessage":"configuration must include Subnets","messagePattern":"configuration must include Subnets","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/toolbox_instance-selector.go","lineNumber":391,"sourceCode":"\nfunc retrieveClusterRefs(ctx context.Context, f commandutils.Factory, clusterName string) (simple.Clientset, *kops.Cluster, *kops.Channel, error) {\n\tclientset, err := f.KopsClient()\n\tif err != nil {\n\t\treturn nil, nil, nil, err\n\t}\n\n\tcluster, err := GetCluster(ctx, f, clusterName)\n\tif err != nil {\n\t\treturn nil, nil, nil, err\n\t}\n\n\tchannel, err := cloudup.ChannelForCluster(clientset.VFSContext(), cluster)\n\tif err != nil {\n\t\treturn nil, nil, nil, err\n\t}\n\n\tif len(cluster.Spec.Networking.Subnets) == 0 {\n\t\treturn nil, nil, nil, fmt.Errorf(\"configuration must include Subnets\")\n\t}\n\n\treturn clientset, cluster, channel, nil\n}\n\nfunc getFilters(commandline *cli.CommandLineInterface, region string, zones []string) selector.Filters {\n\tflags := commandline.Flags\n\tvar cpuArch ec2types.ArchitectureType\n\tif v, ok := flags[cpuArchitecture]; ok {\n\t\tcpuArch = ec2types.ArchitectureType(*commandline.StringMe(v))\n\t}\n\tvar uc ec2types.UsageClassType\n\tif v, ok := flags[usageClass]; ok {\n\t\tuc = ec2types.UsageClassType(*commandline.StringMe(v))\n\t}\n\treturn selector.Filters{\n\t\tVCpusRange:             commandline.Int32RangeMe(flags[vcpus]),\n\t\tMemoryRange:            commandline.ByteQuantityRangeMe(flags[memory]),","sourceCodeStart":373,"sourceCodeEnd":409,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/toolbox_instance-selector.go#L373-L409","documentation":"retrieveClusterRefs loads the cluster from the state store and its channel, then asserts the cluster spec declares networking subnets. Subnets are mandatory because instance groups are placed into them (zone derivation uses these subnet entries), so a cluster without subnets cannot be used by the instance-selector.","triggerScenarios":"Running `kops toolbox instance-selector` against a cluster whose manifest (or state store spec) has an empty cluster.Spec.Networking.Subnets list — e.g. a hand-edited or newly created cluster manifest that omitted subnets before instance groups were defined.","commonSituations":"Manually authored cluster YAML missing the `subnets:` section under spec.networking; a cluster created by tooling that defers subnet assignment; editing out subnets while refactoring the manifest.","solutions":["Add subnets to the cluster spec: `kops edit cluster <name>` and list subnets under spec.networking.subnets with proper type (e.g. public/private) and zones.","Alternatively recreate the cluster manifest via `kops create cluster --zones ...` so subnets are generated.","Confirm you are pointing at the intended cluster (`--name`) — another cluster in the state store may lack subnets.","Run `kops validate cluster` / `kops get cluster -o yaml` to inspect the persisted spec before retrying."],"exampleFix":"// before (cluster.yaml)\nspec:\n  networking:\n    nonMasqueradeCIDR: 100.64.0.0/10\n// after\nspec:\n  networking:\n    nonMasqueradeCIDR: 100.64.0.0/10\n    subnets:\n      - name: us-east-1a\n        type: Public\n        zone: us-east-1a\n        cidr: 172.20.32.0/19","handlingStrategy":"validation","validationCode":"// Before running the selector:\nclusterYaml=$(kops get cluster \"$CLUSTER\" -o yaml)\necho \"$clusterYaml\" | grep -q 'subnets:' || { echo \"cluster has no subnets; edit cluster first\"; exit 1; }","typeGuard":null,"tryCatchPattern":"cluster, _, _, err := retrieveClusterRefs(clientset, cluster)\nif err != nil {\n\tif strings.Contains(err.Error(), \"must include Subnets\") {\n\t\treturn fmt.Errorf(\"cluster %s lacks subnets; run `kops edit cluster` and add spec.networking.subnets\", clusterName)\n\t}\n\treturn err\n}","preventionTips":["Never hand-author a cluster manifest without spec.networking.subnets.","Run `kops get cluster -o yaml | grep subnets` before toolbox commands.","Create clusters via `kops create cluster --zones` so subnets are generated automatically."],"tags":["cluster-spec","validation","subnets"],"backgroundTag":"missing-required-cluster-subnets","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}