kubernetes/kops · error
unhandled LoadBalancer type %q
Error message
unhandled LoadBalancer type %q
What it means
The GCE API load balancer Build method (pkg/model/gcemodel/api_loadbalancer.go:422) switches on spec.api.loadBalancer.type and only implements the supported cases (e.g. public/internal); any other value falls to the default branch and returns 'unhandled LoadBalancer type'. It is a compile-time-style enum guard ensuring the model never silently skips LB creation.
Source
Thrown at pkg/model/gcemodel/api_loadbalancer.go:422
return err
}
// We always create the internal load balancer also;
// it allows us to restrict access to only the nodes.
if err := b.createInternalLB(c); err != nil {
return err
}
return b.addFirewallRules(c)
case kops.LoadBalancerTypeInternal:
if err := b.createInternalLB(c); err != nil {
return err
}
return b.addFirewallRules(c)
default:
return fmt.Errorf("unhandled LoadBalancer type %q", lbSpec.Type)
}
}
View on GitHub (pinned to 4c8573c808)
Solutions
- Set spec.api.loadBalancer.type to a valid GCP-supported value ('public' or 'internal')
- Remove the api.loadBalancer block entirely to use DNS-based endpoints instead
- Dump the spec with 'kops get cluster -o yaml' to spot typos, casing, or empty values
- After fixing, run 'kops update cluster' to regenerate the GCE LB tasks
Example fix
// before
api:
loadBalancer:
type: ""
// after
api:
loadBalancer:
type: internal Defensive patterns
Strategy: validation
Validate before calling
t := cluster.Spec.API.LoadBalancer.Type
switch t {
case kops.LoadBalancerTypePublic, kops.LoadBalancerTypeInternal, "":
// "" only valid if the whole loadBalancer block is omitted
default:
return fmt.Errorf("GCP: unsupported api.loadBalancer.type %q", t)
} Type guard
func supportedGCPAPIType(spec *kops.ClusterSpec) bool {
lb := spec.API.LoadBalancer
return lb == nil || lb.Type == kops.LoadBalancerTypePublic || lb.Type == kops.LoadBalancerTypeInternal
} Prevention
- Set type: public or type: internal explicitly on GCP clusters
- Omit the whole api.loadBalancer block rather than leaving an empty one
- Diff cluster specs against a known-good GCP example before applying
- Run kops update in dry-run/target=terraform mode to catch model errors early
When it happens
Trigger: Building the GCE model for a cluster whose spec.api.loadBalancer.type is not one of the values handled by the switch — usually an empty string (loadBalancer block present but type omitted), or an invalid/foreign enum value pasted into the spec.
Common situations: Copy-pasting a loadBalancer block from AWS clusters into a GCP spec; leaving 'type:' blank after editing; schema drift between kOps versions changing the LoadBalancerType enum.
Related errors
- unhandled LoadBalancer type %q
- instance group %q has %d zones, which is not yet supported f
- found multiple instance groups matching MIG %q
- error creating kops config template: %w
- error creating gcp machine template: %w
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/936bedf091e73583.
Report an issue: GitHub.