kubernetes/kops · error

error building DNS provider: %v

Error message

error building DNS provider: %v

What it means

DNS() lazily constructs the DNS provider (the digitalocean dnsprovider plugin, per dns.ProviderName) via dnsprovider.GetDnsProvider with a nil config. The error is whatever the DNS provider registry/constructor returned, wrapped with context. Since nil config is passed, the provider must be able to self-configure (typically from the DO_ACCESS_TOKEN env var).

Source

Thrown at upup/pkg/fi/cloudup/do/cloud.go:193

func (c *doCloudImplementation) DetachInstance(i *cloudinstances.CloudInstance) error {
	klog.V(8).Info("digitalocean cloud provider DetachInstance not implemented yet")
	return fmt.Errorf("digital ocean cloud provider does not support surging")
}

// ProviderID returns the kops api identifier for DigitalOcean cloud provider
func (c *doCloudImplementation) ProviderID() kops.CloudProviderID {
	return kops.CloudProviderDO
}

// Region returns the DO region we will target
func (c *doCloudImplementation) Region() string {
	return c.region
}

func (c *doCloudImplementation) DNS() (dnsprovider.Interface, error) {
	provider, err := dnsprovider.GetDnsProvider(dns.ProviderName, nil)
	if err != nil {
		return nil, fmt.Errorf("error building DNS provider: %v", err)
	}
	return provider, nil
}

// KeysService returns an implementation of godo.KeysService
func (c *doCloudImplementation) KeysService() godo.KeysService {
	return c.Client.Keys
}

// Volumes returns an implementation of godo.StorageService
func (c *doCloudImplementation) VolumeService() godo.StorageService {
	return c.Client.Storage
}

// VolumeActions returns an implementation of godo.StorageActionsService
func (c *doCloudImplementation) VolumeActionService() godo.StorageActionsService {
	return c.Client.StorageActions
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Export DO_ACCESS_TOKEN with a valid DigitalOcean API token before running kOps.
  2. Verify the cluster spec uses a DNS setup compatible with the DO provider and that the dns-provider plugin is compiled in.
  3. Run with klog verbosity to see the underlying wrapped error from GetDnsProvider for the exact cause.
  4. If using external DNS instead, ensure the cluster's DNS configuration doesn't route through this provider.

Example fix

// before
provider, err := dnsprovider.GetDnsProvider(dns.ProviderName, nil)
// after (caller-side environment guard)
if os.Getenv("DO_ACCESS_TOKEN") == "" {
    return nil, fmt.Errorf("DO_ACCESS_TOKEN must be set to build the DigitalOcean DNS provider")
}
provider, err := dnsprovider.GetDnsProvider(dns.ProviderName, nil)
Defensive patterns

Strategy: validation

Validate before calling

if os.Getenv("DO_ACCESS_TOKEN") == "" {
    return fmt.Errorf("DO_ACCESS_TOKEN must be set before building the DO DNS provider")
}
_, _, err := client.Domains.List(context.TODO(), nil)
if err != nil { return fmt.Errorf("DO token invalid for DNS: %w", err) }

Try / catch

provider, err := cloud.DNS()
if err != nil {
    return fmt.Errorf("check DO_ACCESS_TOKEN and dns provider registration: %w", err)
}

Prevention

When it happens

Trigger: dnsprovider.GetDnsProvider fails because the 'digitalocean' provider is not registered (plugin/dependency missing), or its constructor fails — usually because the DO API token environment variable is unset/invalid, or the provider config cannot be read.

Common situations: Missing DO_ACCESS_TOKEN when running kOps against DO; building a trimmed kOps binary without the DO DNS provider registered; typos in DNS configuration for the cluster.

Related errors


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