{"record":{"id":"181c8880c376714b","repo":"kubernetes/kops","slug":"error-assigning-default-machine-type-for-bastions","errorCode":null,"errorMessage":"error assigning default machine type for bastions: %v","messagePattern":"error assigning default machine type for bastions: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/new_cluster.go","lineNumber":536,"sourceCode":"\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// TODO: Clean up\n\t\tif g.IsControlPlane() {\n\t\t\tif g.Spec.MachineType == \"\" {\n\t\t\t\tg.Spec.MachineType, err = defaultMachineType(cloud, cluster, ig)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"error assigning default machine type for control plane: %v\", err)\n\t\t\t\t}\n\n\t\t\t}\n\t\t} else if g.Spec.Role.HasBastion() {\n\t\t\tif g.Spec.MachineType == \"\" {\n\t\t\t\tg.Spec.MachineType, err = defaultMachineType(cloud, cluster, g)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"error assigning default machine type for bastions: %v\", err)\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif g.IsAPIServerOnly() && !featureflag.APIServerNodes.Enabled() {\n\t\t\t\treturn nil, fmt.Errorf(\"apiserver nodes requires the APIServerNodes feature flag to be enabled\")\n\t\t\t}\n\t\t\tif !featureflag.ExperimentalRoles.Enabled() {\n\t\t\t\tswitch {\n\t\t\t\tcase g.Spec.Role.HasEtcd():\n\t\t\t\t\treturn nil, fmt.Errorf(\"etcd nodes requires the ExperimentalRoles feature flag to be enabled\")\n\t\t\t\tcase g.Spec.Role.HasScheduler():\n\t\t\t\t\treturn nil, fmt.Errorf(\"scheduler nodes requires the ExperimentalRoles feature flag to be enabled\")\n\t\t\t\tcase g.Spec.Role.HasKubeControllerManager():\n\t\t\t\t\treturn nil, fmt.Errorf(\"kube-controller-manager nodes requires the ExperimentalRoles feature flag to be enabled\")\n\t\t\t\t}\n\t\t\t}\n\t\t\tif g.Spec.MachineType == \"\" {\n\t\t\t\tg.Spec.MachineType, err = defaultMachineType(cloud, cluster, g)","sourceCodeStart":518,"sourceCodeEnd":554,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/new_cluster.go#L518-L554","documentation":"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.","triggerScenarios":"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.","commonSituations":"`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.","solutions":["Set an explicit bastion machine type: `--bastion-size=t3.micro` (AWS) or set spec.machineType on the bastion instance group.","Inspect the wrapped underlying error and address the cloud API cause.","Re-run after verifying credentials/region support for the default family."],"exampleFix":"// before\nkops create cluster --name=example.com --bastion\n// after\nkops create cluster --name=example.com --bastion --bastion-size=t3.micro","handlingStrategy":"validation","validationCode":"if bastionIG != nil && bastionIG.Spec.MachineType == \"\" {\n    bastionIG.Spec.MachineType = \"t3.micro\"\n}","typeGuard":null,"tryCatchPattern":"_, err := NewCluster(opt, cluster, zoneMap)\nif err != nil {\n    if strings.Contains(err.Error(), \"default machine type for bastions\") {\n        return fmt.Errorf(\"set --bastion-size explicitly or fix cloud API access: %w\", err)\n    }\n    return err\n}","preventionTips":["Pass --bastion-size whenever --bastion is used","Confirm region supports the default bastion family","Pre-validate cloud API connectivity before kops create"],"tags":["bastion","machine-type","cloud-api","kops"],"backgroundTag":"default-value-lookup-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}