{"record":{"id":"12c27939be181525","repo":"kubernetes/kops","slug":"failed-to-find-network-for-loadbalancer-q","errorCode":null,"errorMessage":"failed to find network for loadbalancer %q","messagePattern":"failed to find network for loadbalancer %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/hetznertasks/loadbalancer.go","lineNumber":235,"sourceCode":"\t\t}\n\t\tif len(e.Services) == 0 {\n\t\t\treturn fi.RequiredField(\"Services\")\n\t\t}\n\t\tif e.Target == \"\" {\n\t\t\treturn fi.RequiredField(\"Target\")\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc (_ *LoadBalancer) RenderHetzner(t *hetzner.HetznerAPITarget, a, e, changes *LoadBalancer) error {\n\tctx := context.TODO()\n\tactionClient := t.Cloud.ActionClient()\n\tclient := t.Cloud.LoadBalancerClient()\n\n\tif a == nil {\n\t\tif e.Network == nil {\n\t\t\treturn fmt.Errorf(\"failed to find network for loadbalancer %q\", fi.ValueOf(e.Name))\n\t\t}\n\n\t\tnetworkID, err := strconv.ParseInt(fi.ValueOf(e.Network.ID), 10, 64)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to convert network ID %q to int: %w\", fi.ValueOf(e.Network.ID), err)\n\t\t}\n\n\t\topts := hcloud.LoadBalancerCreateOpts{\n\t\t\tName: fi.ValueOf(e.Name),\n\t\t\tLoadBalancerType: &hcloud.LoadBalancerType{\n\t\t\t\tName: e.Type,\n\t\t\t},\n\t\t\tAlgorithm: &hcloud.LoadBalancerAlgorithm{\n\t\t\t\tType: hcloud.LoadBalancerAlgorithmTypeRoundRobin,\n\t\t\t},\n\t\t\tLocation: &hcloud.Location{\n\t\t\t\tName: e.Location,\n\t\t\t},","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/hetznertasks/loadbalancer.go#L217-L253","documentation":"In RenderHetzner, when creating a NEW load balancer (a == nil), the task requires e.Network (the Hetzner network the LB should join) because the create call passes a network ID and targets use UsePrivateIP. This error is thrown when the LoadBalancer task has no Network set, so kOps cannot resolve the networkID for hcloud LoadBalancerCreateOpts.","triggerScenarios":"A Hetzner cluster is applied without a network defined in the cluster spec, so the LoadBalancer task's Network field is nil at render time; or the task graph omitted the Network dependency when constructing the LoadBalancer task.","commonSituations":"Cluster spec missing spec.networking.hetzner / network configuration; hand-edited or partial cluster manifest; version mismatch where the load balancer was introduced requiring a network the cluster never had.","solutions":["Add the Hetzner network configuration to the cluster spec so the LoadBalancer task gets a Network, then re-run kops update cluster --yes.","Ensure the cluster's network task is created before the load balancer (check the task builder wiring so e.Network is populated via dependencies).","If a networkless LB is truly desired, the create path must be changed to omit the Network/UsePrivateIP fields — this is not supported by the current kOps Hetzner implementation, so do not bypass it."],"exampleFix":"// before: cluster.yaml without hetzner network\nspec:\n  networkID: \"\"   # no network -> LoadBalancer task has Network == nil\n// after: define the network in the cluster spec so the LB task resolves it\nspec:\n  network:\n    networkID: \"1234567\"\n    zone: fsn1-dc14","handlingStrategy":"validation","validationCode":"if e.Network == nil || fi.ValueOf(e.Network.ID) == \"\" {\n    return fmt.Errorf(\"hetzner load balancer %q requires a network; set networkID in the cluster spec\", fi.ValueOf(e.Name))\n}\nif _, err := strconv.ParseInt(fi.ValueOf(e.Network.ID), 10, 64); err != nil {\n    return fmt.Errorf(\"network ID %q is not numeric\", fi.ValueOf(e.Network.ID))\n}","typeGuard":"func hasNetwork(e *LoadBalancer) bool {\n    return e.Network != nil && fi.ValueOf(e.Network.ID) != \"\"\n}","tryCatchPattern":null,"preventionTips":["Always configure a Hetzner network in the cluster spec before enabling load balancers","Validate the cluster manifest (kops edit / kops validate) so missing network fields are caught pre-apply","Keep the Network dependency wired in the task builder so the ID is populated before RenderHetzner"],"tags":["hetzner","loadbalancer","networking","configuration"],"backgroundTag":"missing-required-config","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"}