kubernetes/kops · error

load balancer has no LoadBalancerName

Error message

load balancer %q has no LoadBalancerName

What it means

During ASG creation, each referenced LoadBalancer task must carry a concrete LoadBalancerName (set only after the ELB task has been found/created). A nil name means the load balancer task was never resolved, so the ASG cannot attach to it.

Solutions

  1. Ensure the loadBalancer(s) are defined as full LoadBalancer tasks in the cluster/instance-group spec so kOps resolves their names
  2. Run `kops update cluster` (full apply, not a partial/targeted run) so the LB task renders before the ASG
  3. If migrating between classic ELB and target-group attachments, update the spec consistently
  4. Check for kops version mismatches between state store and CLI

Example fix

null
Defensive patterns

Strategy: validation

Validate before calling

// ensure every loadBalancer referenced in instance group spec resolves to a named LB task
for _, ig := range instanceGroups {
  for _, lb := range ig.Spec.LoadBalancers {
    if lb.LoadBalancerName == nil && lb.TargetGroupARN == nil {
      return fmt.Errorf("instance group %s references unresolved load balancer", ig.Name)
    }
  }
}

Type guard

func lbHasName(k awstasks.LoadBalancer) bool { return k.LoadBalancerName != nil }

Try / catch

null

Prevention

When it happens

Trigger: RenderAWS builds CreateAutoScalingGroupInput with e.LoadBalancers where some element has LoadBalancerName == nil — e.g. the LB ref points to a task that was never rendered/created in this run, or spec wires a loadBalancer whose name kOps could not determine.

Common situations: Cluster spec references an external/incompletely-defined load balancer, or an older cluster spec where classic ELB attachment tasks were renamed/removed during upgrades.

Related errors


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

Appendix: source

Thrown at upup/pkg/fi/cloudup/awstasks/autoscalinggroup.go:377

			AutoScalingGroupName:             e.Name,
			MinSize:                          e.MinSize,
			MaxSize:                          e.MaxSize,
			NewInstancesProtectedFromScaleIn: e.InstanceProtection,
			Tags:                             v.AutoscalingGroupTags(),
			VPCZoneIdentifier:                new(strings.Join(e.AutoscalingGroupSubnets(), ",")),
			CapacityRebalance:                e.CapacityRebalance,
		}

		//On ASG creation 0 value is forbidden
		if fi.ValueOf(e.MaxInstanceLifetime) == 0 {
			request.MaxInstanceLifetime = nil
		} else {
			request.MaxInstanceLifetime = e.MaxInstanceLifetime
		}

		for _, k := range e.LoadBalancers {
			if k.LoadBalancerName == nil {
				return fmt.Errorf("load balancer %q has no LoadBalancerName", fi.ValueOf(k.GetName()))
			}
			request.LoadBalancerNames = append(request.LoadBalancerNames, aws.ToString(k.LoadBalancerName))
		}

		for _, tg := range e.TargetGroups {
			request.TargetGroupARNs = append(request.TargetGroupARNs, aws.ToString(tg.ARN))
		}

		// @check are we using mixed instances policy, or launch template
		if e.UseMixedInstancesPolicy() {
			request.MixedInstancesPolicy = &autoscalingtypes.MixedInstancesPolicy{
				InstancesDistribution: &autoscalingtypes.InstancesDistribution{
					OnDemandAllocationStrategy:          e.MixedOnDemandAllocationStrategy,
					OnDemandPercentageAboveBaseCapacity: e.MixedOnDemandAboveBase,
					OnDemandBaseCapacity:                e.MixedOnDemandBase,
					SpotAllocationStrategy:              e.MixedSpotAllocationStrategy,
					SpotInstancePools:                   e.MixedSpotInstancePools,
					SpotMaxPrice:                        e.MixedSpotMaxPrice,

View on GitHub (pinned to 4c8573c808)