{"record":{"id":"178f007338276d35","repo":"kubernetes/kops","slug":"could-not-find-subnet-for-kubernetes-api-loadbalan","errorCode":null,"errorMessage":"could not find subnet for Kubernetes API loadbalancer","messagePattern":"could not find subnet for Kubernetes API loadbalancer","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/model/openstackmodel/servergroup.go","lineNumber":312,"sourceCode":"\n\tfor _, s := range sgs {\n\t\tc.AddTask(s)\n\t}\n\n\tif b.Cluster.Spec.CloudProvider.Openstack.Loadbalancer != nil {\n\t\tvar lbSubnetName string\n\t\tvar err error\n\t\tfor _, sp := range b.Cluster.Spec.Networking.Subnets {\n\t\t\tif sp.Type == kops.SubnetTypeDualStack || sp.Type == kops.SubnetTypePrivate {\n\t\t\t\tlbSubnetName, err = b.findSubnetNameByID(sp.ID, sp.Name)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif lbSubnetName == \"\" {\n\t\t\treturn fmt.Errorf(\"could not find subnet for Kubernetes API loadbalancer\")\n\t\t}\n\n\t\tlbTask := &openstacktasks.LB{\n\t\t\tName:      new(b.APIResourceName()),\n\t\t\tSubnet:    new(lbSubnetName),\n\t\t\tLifecycle: b.Lifecycle,\n\t\t}\n\n\t\tif b.Cluster.Spec.CloudProvider.Openstack.Loadbalancer.FlavorID != nil {\n\t\t\tlbTask.FlavorID = b.Cluster.Spec.CloudProvider.Openstack.Loadbalancer.FlavorID\n\t\t}\n\n\t\tuseVIPACL := b.UseVIPACL()\n\t\tif !useVIPACL {\n\t\t\tlbTask.SecurityGroup = b.LinkToSecurityGroup(b.APIResourceName())\n\t\t}\n\n\t\tc.AddTask(lbTask)","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/model/openstackmodel/servergroup.go#L294-L330","documentation":"An explicit OpenStack load balancer is configured for the API, but no subnet of type Private (or DualStack) exists in spec.networking.subnets. The builder scans for the first private subnet to attach the LB to; finding none triggers this validation guard.","triggerScenarios":"Thrown at pkg/model/openstackmodel/servergroup.go:312 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add a private (or dual-stack) subnet to spec.networking.subnets","Remove cloudProvider.openstack.loadbalancer so the default LB placement is used","Verify existing subnets have the correct type field"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}