kubernetes/kops · error

subnet %q has unknown type %q

Error message

subnet %q has unknown type %q

What it means

During CIDR assignment, kOps classifies each subnet by its type (Public/Private/Internal/Utility/DualStack variants). This error is thrown when a subnet's type does not match any known kops.SubnetType, so kOps cannot decide whether to treat it as a 'big' or 'little' subnet for CIDR allocation.

Source

Thrown at upup/pkg/fi/cloudup/subnets.go:155

		if subnet.CIDR != "" {
			_, cidrSubnet, err := net.ParseCIDR(subnet.CIDR)
			if err != nil {
				return fmt.Errorf("invalid subnet %q CIDR: %q", subnet.Name, subnet.CIDR)
			}
			// Skip additional subnets
			if !cidr.Contains(cidrSubnet.IP) {
				continue
			}
		}
		switch subnet.Type {
		case kops.SubnetTypeDualStack, kops.SubnetTypePublic, kops.SubnetTypePrivate:
			bigSubnets = append(bigSubnets, subnet)

		case kops.SubnetTypeUtility:
			littleSubnets = append(littleSubnets, subnet)

		default:
			return fmt.Errorf("subnet %q has unknown type %q", subnet.Name, subnet.Type)
		}

		if subnet.CIDR != "" {
			_, subnetCIDR, err := net.ParseCIDR(subnet.CIDR)
			if err != nil {
				return fmt.Errorf("subnet %q has unexpected CIDR %q", subnet.Name, subnet.CIDR)
			}

			reserved = append(reserved, subnetCIDR)
		}
	}

	// Assign a consistent order
	sort.Sort(ByZone(bigSubnets))
	sort.Sort(ByZone(littleSubnets))

	// Check how many subnet slices are needed
	cidrCount := len(bigSubnets)

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Set the subnet type to a valid kops.SubnetType value (Public, Private, Utility, Internal) in the cluster spec
  2. Run `kops edit cluster` instead of hand-editing so enum values are constrained
  3. Check the kops API version in the manifest and upgrade/downgrade kops so the type names match the API version

Example fix

// before
subnets:
- name: us-east-1a
  type: privte
// after
subnets:
- name: us-east-1a
  type: Private
Defensive patterns

Strategy: validation

Validate before calling

validTypes := map[string]bool{"Public":true,"Private":true,"Utility":true,"Internal":true}
for _, s := range subnets {
	if !validTypes[s.Type] { return fmt.Errorf("subnet %q: unknown type %q", s.Name, s.Type) }
}

Type guard

func knownSubnetType(t kops.SubnetType) bool {
	switch t {
	case kops.SubnetTypePublic, kops.SubnetTypePrivate, kops.SubnetTypeUtility, kops.SubnetTypeInternal:
		return true
	}
	return false
}

Try / catch

if err := PerformAssignments(c, cloud); err != nil {
	if strings.Contains(err.Error(), "unknown type") { /* correct subnet Type in manifest */ }
	return err
}

Prevention

When it happens

Trigger: cluster.spec.networking.subnets[i].type set to a value other than Public, Private, Utility, Internal, DualStack-Legacy, DualStack-Public, etc. — typically a misspelling or a type dropped in a kOps version upgrade.

Common situations: Typo like 'pubic' or 'private' (wrong case) in cluster.yaml; specs written for an older kOps version using a removed type name; hand-generated manifests from custom tooling.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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