kubernetes/kops · error

unknown load balancer Type: %q

Error message

unknown load balancer Type: %q

What it means

During AWS model building, kOps maps the cluster spec's api.loadBalancer.type to an ELBv2 scheme. Only the enum values 'Internal' and 'Public' are accepted; anything else makes BuildNodePortTask/Build fail with this error rather than guessing a scheme.

Source

Thrown at pkg/model/awsmodel/api_loadbalancer.go:228

		if b.Cluster.UsesLoadBalancerForKopsController() {
			nlb.SetWaitForLoadBalancerReady(true)
		}

		if b.Cluster.UsesLoadBalancerForKopsController() {
			lbSpec.CrossZoneLoadBalancing = new(true)
		} else if lbSpec.CrossZoneLoadBalancing == nil {
			lbSpec.CrossZoneLoadBalancing = new(false)
		}

		nlb.CrossZoneLoadBalancing = lbSpec.CrossZoneLoadBalancing

		switch lbSpec.Type {
		case kops.LoadBalancerTypeInternal:
			nlb.Scheme = elbv2types.LoadBalancerSchemeEnumInternal
		case kops.LoadBalancerTypePublic:
			nlb.Scheme = elbv2types.LoadBalancerSchemeEnumInternetFacing
		default:
			return fmt.Errorf("unknown load balancer Type: %q", lbSpec.Type)
		}

		if lbSpec.AccessLog != nil {
			nlb.AccessLog = &awstasks.NetworkLoadBalancerAccessLog{
				Enabled:        new(true),
				S3BucketName:   lbSpec.AccessLog.Bucket,
				S3BucketPrefix: lbSpec.AccessLog.BucketPrefix,
			}
		} else {
			nlb.AccessLog = &awstasks.NetworkLoadBalancerAccessLog{
				Enabled: new(false),
			}
		}

		{
			groupAttrs := map[string]string{
				awstasks.TargetGroupAttributeDeregistrationDelayConnectionTerminationEnabled: "true",
				awstasks.TargetGroupAttributeDeregistrationDelayTimeoutSeconds:               "30",

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Set spec.api.loadBalancer.type in the cluster spec to exactly "public" or "internal" (kops accepts only these kops.LoadBalancerType values, lowercase).
  2. If the field is empty in cluster.yaml, run `kops edit cluster` and add the type explicitly, e.g. `type: Public`.
  3. Check for casing/typo with `kops get cluster -oyaml | grep -A3 loadBalancer` and fix to lowercase internal/public.
  4. Upgrade kOps if a previously valid value stopped working; older/newer schemas may differ — validate with `kops toolbox template` or `kops replace -f` to surface schema errors early.

Example fix

// before (cluster.yaml)
api:
  loadBalancer:
    type: External
// after
api:
  loadBalancer:
    type: Public
Defensive patterns

Strategy: validation

Validate before calling

# validate cluster spec before kops update
type=$(kops get cluster -oyaml | awk '/^[ ]*type:/{print $2}')
case "$type" in
  Public|public|Internal|internal) echo "ok";;
  *) echo "invalid loadBalancer type: '$type' (must be public or internal)"; exit 1;;
esac

Prevention

When it happens

Trigger: `kops update cluster` (or `kops create cluster --api-loadbalancer-type=...`) with spec.api.loadBalancer.type set to a value other than "internal" or "public" (empty string, typo like "internall"/"external", or wrong casing, since the switch is case-sensitive).

Common situations: Hand-edited cluster.yaml with a misspelled or capitalized type; copying config from a classic-ELB-era docs page; tooling that serializes the field as "" when unset; migrating configs where the field was removed/renamed.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/ee4778404dcb50fa. Report an issue: GitHub.