kubernetes/kops · error

error assigning default machine type for nodes: %v

Error message

error assigning default machine type for nodes: %v

What it means

For non-control-plane, non-bastion groups (worker nodes), NewCluster assigns a default machine type when spec.machineType is empty. If the cloud-specific defaultMachineType() call fails, the error is wrapped with this message and creation aborts.

Source

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

			}
		} else {
			if g.IsAPIServerOnly() && !featureflag.APIServerNodes.Enabled() {
				return nil, fmt.Errorf("apiserver nodes requires the APIServerNodes feature flag to be enabled")
			}
			if !featureflag.ExperimentalRoles.Enabled() {
				switch {
				case g.Spec.Role.HasEtcd():
					return nil, fmt.Errorf("etcd nodes requires the ExperimentalRoles feature flag to be enabled")
				case g.Spec.Role.HasScheduler():
					return nil, fmt.Errorf("scheduler nodes requires the ExperimentalRoles feature flag to be enabled")
				case g.Spec.Role.HasKubeControllerManager():
					return nil, fmt.Errorf("kube-controller-manager nodes requires the ExperimentalRoles feature flag to be enabled")
				}
			}
			if g.Spec.MachineType == "" {
				g.Spec.MachineType, err = defaultMachineType(cloud, cluster, g)
				if err != nil {
					return nil, fmt.Errorf("error assigning default machine type for nodes: %v", err)
				}
			}

		}

		if ig.Spec.Tenancy != "" && ig.Spec.Tenancy != "default" {
			switch cluster.GetCloudProvider() {
			case api.CloudProviderAWS:
				if _, ok := awsDedicatedInstanceExceptions[g.Spec.MachineType]; ok {
					return nil, fmt.Errorf("invalid dedicated instance type: %s", g.Spec.MachineType)
				}
			default:
				klog.Warning("Trying to set tenancy on non-AWS environment")
			}
		}

		if ig.IsControlPlane() {
			if len(ig.Spec.Subnets) == 0 {

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Set an explicit node machine type: `--node-size=t3.medium` (AWS) or spec.machineType on node instance groups.
  2. Read the wrapped %v cause and fix the underlying cloud API problem (region, quota, permissions, network).
  3. Retry once the cloud API is reachable and the default family is available in the zone.

Example fix

// before
kops create cluster --name=example.com --zones=eu-west-1a
// after
kops create cluster --name=example.com --zones=eu-west-1a --node-size=t3.medium
Defensive patterns

Strategy: validation

Validate before calling

if nodeIG.Spec.MachineType == "" {
    nodeIG.Spec.MachineType = "t3.medium" // skip cloud default lookup
}

Try / catch

_, err := NewCluster(opt, cluster, zoneMap)
if err != nil {
    if strings.Contains(err.Error(), "default machine type for nodes") {
        return fmt.Errorf("set --node-size explicitly or fix cloud API access: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: `kops create cluster` without specifying node size while the cloud API used to determine defaults fails: bad zone, throttling, credential/permission problems, or family unavailable in region.

Common situations: Automated provisioning with minimal flags in a fresh region; IAM roles missing ec2:Describe* permissions; network egress to cloud API blocked in CI.

Related errors


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