{"record":{"id":"4028132ded50dd54","repo":"kubernetes/kops","slug":"unable-to-determine-ip-address-for-kube-apiserver","errorCode":null,"errorMessage":"unable to determine IP address for kube-apiserver","messagePattern":"unable to determine IP address for kube-apiserver","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/commands/toolbox_enroll.go","lineNumber":743,"sourceCode":"\t{\n\t\tingresses, err := cloud.GetApiIngressStatus(fullCluster)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error getting ingress status: %v\", err)\n\t\t}\n\n\t\tfor _, ingress := range ingresses {\n\t\t\t// TODO: Do we need to support hostnames?\n\t\t\t// if ingress.Hostname != \"\" {\n\t\t\t// \tapiserverAdditionalIPs = append(apiserverAdditionalIPs, ingress.Hostname)\n\t\t\t// }\n\t\t\tif ingress.IP != \"\" {\n\t\t\t\twellKnownAddresses[wellknownservices.KubeAPIServer] = append(wellKnownAddresses[wellknownservices.KubeAPIServer], ingress.IP)\n\t\t\t}\n\t\t}\n\t}\n\tif len(wellKnownAddresses[wellknownservices.KubeAPIServer]) == 0 {\n\t\t// TODO: Should we support DNS?\n\t\treturn nil, fmt.Errorf(\"unable to determine IP address for kube-apiserver\")\n\t}\n\tfor k := range wellKnownAddresses {\n\t\tsort.Strings(wellKnownAddresses[k])\n\t}\n\n\tb.wellKnownAddresses = &wellKnownAddresses\n\treturn wellKnownAddresses, nil\n}\n\nfunc (b *ConfigBuilder) GetBootstrapData(ctx context.Context) (*BootstrapData, error) {\n\tif b.bootstrapData != nil {\n\t\treturn b.bootstrapData, nil\n\t}\n\n\tcluster, err := b.GetFullCluster(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":725,"sourceCodeEnd":761,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/commands/toolbox_enroll.go#L725-L761","documentation":"After enumerating ingress entries, GetWellKnownAddresses requires at least one IP address for the kube-apiserver. If the load balancer returned no usable ingress IPs, it fails with 'unable to determine IP address for kube-apiserver'. DNS-only hostnames are explicitly not supported here (see TODO).","triggerScenarios":"GetApiIngressStatus succeeded but every ingress entry has an empty IP (e.g. NLB with only a DNS hostname, or LB still initializing), leaving wellKnownAddresses[KubeAPIServer] empty.","commonSituations":"Classic ELB or ALB exposing only hostname rather than IP; load balancer just created and no healthy targets/attachments yet; cluster provisioned with a DNS-based API endpoint (spec.api.access or gossip/DNS misconfiguration).","solutions":["Verify the API load balancer has healthy targets and a static IP (prefer NLB with elastic IPs).","Check `kops get cluster -oyaml` spec.api.loadBalancer settings; switch type to NLB so IPs are exposed.","Wait until `kops validate cluster` reports the API endpoint reachable, then retry.","If DNS is the only endpoint, this code path does not support it — provision an IP-based LB or extend the code to support hostnames."],"exampleFix":"// before\n// LB type: ClassicELB exposing only hostname -> no IPs collected\n// after (cluster spec)\n// spec:\n//   api:\n//     loadBalancer:\n//       type: Network  # NLB provides resolvable static IPs","handlingStrategy":"validation","validationCode":"// Verify the LB provides IP-type ingress before enrolling\n// kops get cluster -oyaml | grep -A3 loadBalancer  -> expect type: Network (NLB)","typeGuard":null,"tryCatchPattern":"if err != nil {\n\tif strings.Contains(err.Error(), \"unable to determine IP address\") {\n\t\t// fall back to checking the LB config; NLB with elastic IPs required\n\t}\n\treturn err\n}","preventionTips":["Use NLB (spec.api.loadBalancer.type: Network) so static IPs are exposed","Ensure LB targets are healthy before enrollment","Do not rely on DNS-only endpoints; this path requires IPs"],"tags":["kops","kube-apiserver","load-balancer","dns","ip-address"],"backgroundTag":"no-apiserver-endpoint-ip","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"}