kubernetes/kops · error
DNSName not set on AliasTarget
Error message
DNSName not set on AliasTarget
What it means
findNetworkLoadBalancerByAlias matches an ELBv2 Alias target (e.g. from a Route53 record) against existing NLBs by DNS name. If alias.DNSName is empty after trimming a trailing dot, the function cannot match anything and returns "DNSName not set on AliasTarget".
Source
Thrown at upup/pkg/fi/cloudup/awstasks/network_load_balancer.go:113
var _ fi.CompareWithID = (*NetworkLoadBalancer)(nil)
var _ fi.CloudupTaskNormalize = (*NetworkLoadBalancer)(nil)
var _ fi.CloudupProducesDeletions = (*NetworkLoadBalancer)(nil)
func (e *NetworkLoadBalancer) CompareWithID() *string {
return e.Name
}
func findNetworkLoadBalancerByAlias(cloud awsup.AWSCloud, alias *route53types.AliasTarget) (*elbv2types.LoadBalancer, error) {
ctx := context.TODO()
// TODO: Any way to avoid listing all NLBs?
request := &elbv2.DescribeLoadBalancersInput{}
dnsName := aws.ToString(alias.DNSName)
matchDnsName := strings.TrimSuffix(dnsName, ".")
if matchDnsName == "" {
return nil, fmt.Errorf("DNSName not set on AliasTarget")
}
matchHostedZoneId := aws.ToString(alias.HostedZoneId)
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 {View on GitHub (pinned to 4c8573c808)
Solutions
- Inspect the Route53 record and set the correct AliasTarget DNSName (the NLB's dns name)
- If the record is broken/unwanted, delete or recreate the alias record with a valid target
- Re-run kops update once the alias record carries a DNSName
Example fix
// before (alias target)
{ HostedZoneId: "Z..." } // DNSName missing
// after
{ HostedZoneId: "Z...", DNSName: "k8s-elb-xxx.elb.us-east-1.amazonaws.com" } Defensive patterns
Strategy: validation
Validate before calling
if alias != nil && (alias.DNSName == nil || strings.TrimSuffix(aws.ToString(alias.DNSName), ".") == "") {
return fmt.Errorf("route53 alias target has no DNSName; fix the record before update")
} Type guard
func aliasHasDNSName(a *route53types.AliasTarget) bool {
return a != nil && strings.TrimSuffix(aws.ToString(a.DNSName), ".") != ""
} Prevention
- Inspect Route53 alias records before applying cluster changes
- Never create alias records programmatically without DNSName
- Audit manually edited DNS records in the cluster hosted zone
When it happens
Trigger: Called from findDNSTargetNLB when a Route53 A/AAAA alias record's AliasTarget has a nil or empty DNSName field while kOps tries to determine whether the record already points at an NLB.
Common situations: Corrupt or manually edited Route53 alias record; record built programmatically with DNSName omitted; AWS SDK change exposing nil DNSName on an alias target.
Related errors
- error mapping DNSName %q to LoadBalancer: %v
- Found NLB %q linked to DNS name %q, but it did not have a Na
- error applying DNS changeset for zone %s: %v
- failed to load default aws config for IMDS client: %w
- failed to load default aws config for STS client: %w
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/86f3f0fe9db6deb5.
Report an issue: GitHub.