kubernetes/kops · error

failed to find domain for cluster: %s

Error message

failed to find domain for cluster: %s

What it means

listDNS iterated all DO domains and none of their names is a suffix of the clusterName, so kOps cannot locate which DNS zone hosts the cluster's records. Thrown as a hard failure during resource discovery on delete/dump.

Source

Thrown at pkg/resources/digitalocean/resources.go:156

	return resourceTrackers, nil
}

func listDNS(cloud fi.Cloud, clusterName string) ([]*resources.Resource, error) {
	c := cloud.(do.DOCloud)
	domains, _, err := c.DomainService().List(context.TODO(), &godo.ListOptions{})
	if err != nil {
		return nil, fmt.Errorf("failed to list domains: %s", err)
	}

	var domainName string
	for _, domain := range domains {
		if strings.HasSuffix(clusterName, domain.Name) {
			domainName = domain.Name
		}
	}

	if domainName == "" {
		return nil, fmt.Errorf("failed to find domain for cluster: %s", clusterName)
	}

	records, err := getAllRecordsByDomain(c, domainName)
	if err != nil {
		return nil, fmt.Errorf("failed to list records for domain %s: %s", domainName, err)
	}

	var resourceTrackers []*resources.Resource
	for _, record := range records {
		if !strings.HasSuffix(dns.EnsureDotSuffix(record.Name)+domainName, clusterName) {
			continue
		}

		// kops for digitalocean should only create A records
		// in the future that may change but for now this provides a safe filter
		// in case users assign NS records for the cluster subdomain
		if record.Type != "A" {
			continue

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Ensure a DO domain exists whose name matches the cluster name suffix (doctl compute domain create example.com)
  2. Confirm the cluster name exactly matches the registered kops cluster (kops get clusters)
  3. If DNS is not managed in DO, use the correct --cloud / dns configuration for deletion
  4. Recreate/import the domain if it was deleted accidentally

Example fix

// before
kops delete cluster --name k8s.mistyped.com --cloud digitalocean
// after
kops delete cluster --name k8s.example.com --cloud digitalocean  # matches existing DO domain example.com
Defensive patterns

Strategy: validation

Validate before calling

domainName := ""
for _, d := range domains {
	if strings.HasSuffix(strings.TrimSuffix(clusterName, "."), d.Name) {
		domainName = d.Name
		break
	}
}
if domainName == "" {
	return fmt.Errorf("no DO domain matches cluster %q; existing: %v", clusterName, domainNames(domains))
}

Prevention

When it happens

Trigger: No domain in the DO account satisfies strings.HasSuffix(clusterName, domain.Name), e.g. cluster name "k8s.example.com" but account only has domain "other.com", or the domain was deleted out-of-band.

Common situations: Cluster was created with a DNS zone managed outside DigitalOcean (e.g. Route53) while kops tries the DO listing; domain deleted manually; cluster name typo; trailing dot mismatches.

Related errors


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