kubernetes/kops · error

Found multiple NLBs with DNSName %q

Error message

Found multiple NLBs with DNSName %q

What it means

When more than one NLB matches the alias's DNS name, kOps cannot determine which load balancer the alias targets and returns "Found multiple NLBs with DNSName %q". The lookup deliberately refuses to guess among ambiguous matches.

Source

Thrown at upup/pkg/fi/cloudup/awstasks/network_load_balancer.go:136

	found, err := describeNetworkLoadBalancers(ctx, cloud, request, func(lb elbv2types.LoadBalancer) bool {
		if matchHostedZoneId != aws.ToString(lb.CanonicalHostedZoneId) {
			return false
		}

		lbDnsName := aws.ToString(lb.DNSName)
		lbDnsName = strings.TrimSuffix(lbDnsName, ".")
		return lbDnsName == matchDnsName || "dualstack."+lbDnsName == matchDnsName
	})
	if err != nil {
		return nil, fmt.Errorf("error listing NLBs: %v", err)
	}

	if len(found) == 0 {
		return nil, nil
	}

	if len(found) != 1 {
		return nil, fmt.Errorf("Found multiple NLBs with DNSName %q", dnsName)
	}

	return &found[0], nil
}

func describeNetworkLoadBalancers(ctx context.Context, cloud awsup.AWSCloud, request *elbv2.DescribeLoadBalancersInput, filter func(elbv2types.LoadBalancer) bool) ([]elbv2types.LoadBalancer, error) {
	var found []elbv2types.LoadBalancer
	paginator := elbv2.NewDescribeLoadBalancersPaginator(cloud.ELBV2(), request)
	for paginator.HasMorePages() {
		page, err := paginator.NextPage(ctx)
		if err != nil {
			return nil, fmt.Errorf("listing NLBs: %v", err)
		}
		for _, lb := range page.LoadBalancers {
			if filter(lb) {
				found = append(found, lb)
			}
		}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. List NLBs in the region (aws elbv2 describe-load-balancers) and delete the stale duplicate
  2. Ensure only one NLB carries the DNS name the alias points to
  3. Re-run kops update after cleanup

Example fix

// shell before
aws elbv2 describe-load-balancers # shows two NLBs with same DNS
// after
aws elbv2 delete-load-balancer --load-balancer-arn <stale-arn>
Defensive patterns

Strategy: validation

Validate before calling

// before applying, ensure uniqueness of NLBs by DNS name
lbs, _ := cloud.ELBV2().DescribeLoadBalancers(ctx, &elbv2.DescribeLoadBalancersInput{})
counts := map[string]int{}
for _, lb := range lbs.LoadBalancers { counts[aws.ToString(lb.DNSName)]++ }
for dns, n := range counts { if n > 1 { return fmt.Errorf("duplicate NLBs for %s; clean up first", dns) } }

Prevention

When it happens

Trigger: findNetworkLoadBalancerByAlias's filter (DNSName equal or dualstack.-prefixed match) matched 2+ NLBs from DescribeLoadBalancers while resolving a Route53 alias target.

Common situations: Duplicate NLBs created by repeated applies or leftover clusters sharing a DNS name; a dualstack and a regular NLB both matching; stale NLBs from a previous kOps version.

Related errors


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