kubernetes/kops · error

unknown DNSType: %q

Error message

unknown DNSType: %q

What it means

setupDNSTopology maps the --dns flag to a DNSType in the cluster spec. Only "public", "private", and "none" are accepted; any other value hits the default branch and returns this error quoting the provided string.

Source

Thrown at upup/pkg/fi/cloudup/new_cluster.go:1537

func setupDNSTopology(opt *NewClusterOptions, cluster *api.Cluster) error {
	switch strings.ToLower(opt.DNSType) {
	case "":
		if opt.DNSZone != "" {
			// Use dns=public if zone is specified
			cluster.Spec.Networking.Topology.DNS = api.DNSTypePublic
		} else {
			// Default to dns=none instead of dns=public for all cloud providers
			cluster.Spec.Networking.Topology.DNS = api.DNSTypeNone
		}
	case "public":
		cluster.Spec.Networking.Topology.DNS = api.DNSTypePublic
	case "private":
		cluster.Spec.Networking.Topology.DNS = api.DNSTypePrivate
	case "none":
		cluster.Spec.Networking.Topology.DNS = api.DNSTypeNone
	default:
		return fmt.Errorf("unknown DNSType: %q", opt.DNSType)
	}
	return nil
}

func setupAPI(opt *NewClusterOptions, cluster *api.Cluster) error {
	// Populate the API access, so that it can be discoverable
	klog.Infof("Cloud Provider ID: %q", cluster.GetCloudProvider())
	if opt.APILoadBalancerType != "" || opt.APISSLCertificate != "" {
		cluster.Spec.API.LoadBalancer = &api.LoadBalancerAccessSpec{}
	} else {
		switch opt.Topology {
		case api.TopologyPublic:
			if cluster.UsesNoneDNS() {
				// there are no DNS records for the API, so we use a LoadBalancer instead
				cluster.Spec.API.LoadBalancer = &api.LoadBalancerAccessSpec{}
			} else {
				cluster.Spec.API.DNS = &api.DNSAccessSpec{}
			}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Pass --dns public, --dns private, or --dns none (lowercase).
  2. Remove the --dns flag to use the default.
  3. Fix the shell variable feeding the flag so it expands to a valid value.

Example fix

// before
kops create cluster my.cluster --dns Public
// after
kops create cluster my.cluster --dns public
Defensive patterns

Strategy: validation

Validate before calling

case "$DNS" in public|private|none|"") ;; *) echo "--dns must be public|private|none"; exit 1;; esac

Try / catch

if err := createCluster(); err != nil && strings.Contains(err.Error(), "unknown DNSType") { /* fix --dns value (lowercase) and retry */ }

Prevention

When it happens

Trigger: `kops create cluster --dns <value>` with a value outside {public, private, none}, e.g. --dns Public (case-sensitive), --dns "", or --dns aws from a misremembered option.

Common situations: Case mistakes (Public/Private); empty --dns from unset environment variables; assuming other DNS modes exist; old scripts using removed values.

Understand the failure class

Background: "unknown output mode", "invalid value for flag", "expects true/false": fixing invalid flag value errors in CLI tools — this error's family across 24 libraries.

Related errors


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