kubernetes/kops · error

error assigning default machine type for bastions: %v

Error message

error assigning default machine type for bastions: %v

What it means

Same defaulting path as the control-plane case, but for bastion instance groups: if a bastion group has no machine type, kops calls defaultMachineType() and wraps any failure with this message. Cluster creation aborts before any infrastructure is built.

Source

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

					return nil, err
				}
			}
		}

		// TODO: Clean up
		if g.IsControlPlane() {
			if g.Spec.MachineType == "" {
				g.Spec.MachineType, err = defaultMachineType(cloud, cluster, ig)
				if err != nil {
					return nil, fmt.Errorf("error assigning default machine type for control plane: %v", err)
				}

			}
		} else if g.Spec.Role.HasBastion() {
			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 bastions: %v", err)
				}
			}
		} 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)

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Set an explicit bastion machine type: `--bastion-size=t3.micro` (AWS) or set spec.machineType on the bastion instance group.
  2. Inspect the wrapped underlying error and address the cloud API cause.
  3. Re-run after verifying credentials/region support for the default family.

Example fix

// before
kops create cluster --name=example.com --bastion
// after
kops create cluster --name=example.com --bastion --bastion-size=t3.micro
Defensive patterns

Strategy: validation

Validate before calling

if bastionIG != nil && bastionIG.Spec.MachineType == "" {
    bastionIG.Spec.MachineType = "t3.micro"
}

Try / catch

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

Prevention

When it happens

Trigger: Creating a cluster with a bastion group (`--bastion` or explicit bastion IG) with no machine type set while the cloud lookup fails — API error, unsupported region, insufficient credentials.

Common situations: `kops create cluster --bastion` in a region where the default instance family is unavailable; cloud API throttling or connectivity issues; IAM policy too restrictive to describe instance types.

Related errors


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