{"record":{"id":"4b408162adfdc286","repo":"kubernetes/kops","slug":"expected-exactly-one-subnet-for-instancegroup-q-4b4081","errorCode":null,"errorMessage":"expected exactly one subnet for InstanceGroup %q; subnets was %s","messagePattern":"expected exactly one subnet for InstanceGroup %q; subnets was (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/model/linodemodel/instances.go","lineNumber":54,"sourceCode":"\tSSHKeyLifecycle        fi.Lifecycle\n\tBootstrapScriptBuilder *model.BootstrapScriptBuilder\n}\n\nvar _ fi.CloudupModelBuilder = &InstanceModelBuilder{}\n\nfunc (b *InstanceModelBuilder) Build(c *fi.CloudupModelBuilderContext) error {\n\tsshKeyTask, err := b.buildSSHKeyTask(c)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfor _, ig := range b.InstanceGroups {\n\t\tsubnets, err := b.GatherSubnets(ig)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif len(subnets) != 1 {\n\t\t\treturn fmt.Errorf(\"expected exactly one subnet for InstanceGroup %q; subnets was %s\", ig.Name, ig.Spec.Subnets)\n\t\t}\n\t\tsubnetSpec := subnets[0]\n\t\tsubnetTaskName := linode.NormalizeLinodeLabel(b.ClusterName() + \"-\" + subnetSpec.Name)\n\t\tsubnetTask, err := findSubnetTask(c, subnetTaskName, ig)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tuserData, err := b.BootstrapScriptBuilder.ResourceNodeUp(c, ig)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\ttagsMap, err := b.CloudTagsForInstanceGroup(ig)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\ttags := make([]string, 0, len(tagsMap))","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/model/linodemodel/instances.go#L36-L72","documentation":"During kOps cluster spec building for Akamai (Linode), InstanceModelBuilder.Build() maps each InstanceGroup to exactly one Linode VPC subnet. GatherSubnets resolves the instance group's subnet names to subnet specs, and if the group resolves to zero or more than one subnet, build fails with this error because a Linode instance must live in a single subnet/region.","triggerScenarios":"Running kops update/create cluster on a Linode cluster where an InstanceGroup's spec.subnets lists multiple subnet names, or the subnet list is empty, or GatherSubnets silently yields multiple matches (e.g. duplicate subnet names in cluster.spec.networking.subnets).","commonSituations":"Copying an AWS cluster manifest (which allows multi-subnet instance groups across AZs) to Linode; adding a second subnet to an instance group intending multi-AZ support; typos merging subnet lists via kops toolbox or cluster template merges.","solutions":["Edit the InstanceGroup manifest so spec.subnets contains exactly one subnet name (e.g. subnets: [\"us-east-1a\"]).","If multi-AZ is needed on Linode, create a separate InstanceGroup per subnet/region instead of one group with many subnets.","Run kops get instancegroup <name> -o yaml to confirm the current subnets list, then kops replace -f after fixing.","Check the cluster spec for duplicate subnet names that cause GatherSubnets to resolve more than one entry."],"exampleFix":"// before\nmetadata:\n  name: nodes\nspec:\n  subnets:\n  - us-east-1a\n  - us-east-1b\n// after\nmetadata:\n  name: nodes\nspec:\n  subnets:\n  - us-east-1a","handlingStrategy":"validation","validationCode":"ig, _ := kops.GetInstanceGroup(cluster, \"nodes\")\nif len(ig.Spec.Subnets) != 1 {\n    return fmt.Errorf(\"instance group %s must reference exactly one subnet, got %d\", ig.Name, len(ig.Spec.Subnets))\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["On Linode, always give each InstanceGroup exactly one subnet.","Create one InstanceGroup per region/subnet for multi-AZ designs.","Validate manifests with kops toolbox template or kops create --dry-run before applying.","Avoid copying AWS multi-subnet instance group specs to Linode."],"tags":["linode","instancegroup","subnet","configuration"],"backgroundTag":"invalid-subnet-count","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"}