kubernetes/kops · error

could not init DNS provider %q: %v

Error message

could not init DNS provider %q: %v

What it means

dnsprovider.InitDnsProvider wraps any error from GetDnsProvider(name, config|nil) as "could not init DNS provider %q: %v". GetDnsProvider loads the provider plugin/driver by name and constructs the provider from the given configuration; failure means the provider name is unrecognized by registered plugins or the provider rejected the configuration. This is the terminal init error for the DNS provider subsystem.

Source

Thrown at dnsprovider/pkg/dnsprovider/plugins.go:102

	}

	if configFilePath != "" {
		var config *os.File
		config, err = os.Open(configFilePath)
		if err != nil {
			return nil, fmt.Errorf("couldn't open DNS provider configuration %s: %#v", configFilePath, err)
		}

		defer config.Close()
		dns, err = GetDnsProvider(name, config)
	} else {
		// Pass explicit nil so plugins can actually check for nil. See
		// "Why is my nil error value not equal to nil?" in golang.org/doc/faq.
		dns, err = GetDnsProvider(name, nil)
	}

	if err != nil {
		return nil, fmt.Errorf("could not init DNS provider %q: %v", name, err)
	}
	if dns == nil {
		return nil, fmt.Errorf("unknown DNS provider %q", name)
	}

	return dns, nil
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Check the provider name against supported values (aws-route53, google-clouddns, coredns, etc.) and fix the --dns flag.
  2. Read the wrapped '%v' error for the provider-specific cause (bad config vs unknown name).
  3. If the provider is a plugin, ensure it is registered/compiled into the binary you are running.
  4. Validate the configuration file contents against the provider's expected schema.

Example fix

// before: unknown provider name
provider, err := dnsprovider.InitDnsProvider("route53", "")
// after: registered provider name
provider, err := dnsprovider.InitDnsProvider("aws-route53", "")
Defensive patterns

Strategy: fallback

Validate before calling

// Go: check the provider name against the supported set before init
var validProviders = map[string]bool{"aws-route53": true, "google-clouddns": true, "coredns": true, "gossip": true}
if !validProviders[name] {
    return fmt.Errorf("unsupported --dns provider %q", name)
}

Try / catch

provider, err := dnsprovider.InitDnsProvider(name, path)
if err != nil {
    klog.Errorf("DNS provider init failed: %v", err)
    if strings.Contains(err.Error(), "unknown DNS provider") {
        // fall back to a known-good provider, e.g. gossip for local dev
        provider, err = dnsprovider.InitDnsProvider("gossip", "")
    }
}

Prevention

When it happens

Trigger: Calling InitDnsProvider with a provider name that has no registered dnsprovider plugin (e.g. misspelled --dns flag), or where the provider's constructor fails parsing/validating the supplied config reader; the wrapped error carries the provider-specific cause.

Common situations: Unsupported or misspelled --dns value (e.g. 'route53' instead of 'aws-route53'); provider plugin not registered/linked into the binary; malformed provider configuration; cloud SDK auth setup rejected during provider construction.

Related errors


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