kubernetes/kops · error
unknown api-loadbalancer-type: %q
Error message
unknown api-loadbalancer-type: %q
What it means
Returned by setupAPI in `kops create cluster` when the --api-loadbalancer-type flag has a value the switch statement does not recognize. Only empty, "public", and "internal" are accepted; anything else aborts cluster spec creation before any infrastructure is provisioned.
Source
Thrown at upup/pkg/fi/cloudup/new_cluster.go:1572
cluster.Spec.API.DNS = &api.DNSAccessSpec{}
}
case api.TopologyPrivate:
cluster.Spec.API.LoadBalancer = &api.LoadBalancerAccessSpec{}
default:
return fmt.Errorf("unknown topology type: %q", opt.Topology)
}
}
if cluster.Spec.API.LoadBalancer != nil && cluster.Spec.API.LoadBalancer.Type == "" {
switch opt.APILoadBalancerType {
case "", "public":
cluster.Spec.API.LoadBalancer.Type = api.LoadBalancerTypePublic
case "internal":
cluster.Spec.API.LoadBalancer.Type = api.LoadBalancerTypeInternal
default:
return fmt.Errorf("unknown api-loadbalancer-type: %q", opt.APILoadBalancerType)
}
}
if cluster.Spec.API.LoadBalancer != nil && opt.APISSLCertificate != "" {
cluster.Spec.API.LoadBalancer.SSLCertificate = opt.APISSLCertificate
}
if cluster.Spec.API.LoadBalancer != nil && cluster.Spec.API.LoadBalancer.Class == "" && cluster.GetCloudProvider() == api.CloudProviderAWS {
cluster.Spec.API.LoadBalancer.Class = api.LoadBalancerClassNetwork
}
return nil
}
func initializeOpenstack(opt *NewClusterOptions, cluster *api.Cluster) {
if opt.APILoadBalancerType != "" {
cluster.Spec.API.LoadBalancer = &api.LoadBalancerAccessSpec{}
provider := "haproxy"View on GitHub (pinned to 4c8573c808)
Solutions
- Set --api-loadbalancer-type to exactly "public" or "internal" (or omit it for the default)
- Check `kops create cluster --help` for accepted values
- Correct the value in any scripts/addons invoking kops
Example fix
// before kops create cluster ... --api-loadbalancer-type=nlb // after kops create cluster ... --api-loadbalancer-type=public
Defensive patterns
Strategy: validation
Validate before calling
valid := map[string]bool{"": true, "public": true, "internal": true}
if !valid[opt.APILoadBalancerType] {
return fmt.Errorf("--api-loadbalancer-type must be public or internal, got %q", opt.APILoadBalancerType)
} Prevention
- Use only the documented values public/internal
- Add shell-completion or wrapper scripts that validate the flag
- Keep flags in one reviewed config script
When it happens
Trigger: Running `kops create cluster --api-loadbalancer-type=<value>` with a misspelled or unsupported value, e.g. "Public", "private", "nlb", or "external".
Common situations: Typo or wrong casing of the flag value; copying examples from other tools (e.g. "nlb"/"alb" are AWS LB types, not kops values); older docs using deprecated synonyms.
Understand the failure class
Background: "unknown output mode", "invalid value for flag", "expects true/false": fixing invalid flag value errors in CLI tools — this error's family across 24 libraries.
Related errors
- invalid value %q for --instance-manager
- Error too many '=' (%d) in %s
- at least one channel URL is required
- error populating configuration: %v
- spec.PublicKey is required
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/f99636ceb13f457e.
Report an issue: GitHub.