kubernetes/kops · error

cannot select instance types from non-aws cluster

Error message

cannot select instance types from non-aws cluster

What it means

`kops toolbox instance-selector` computes AWS EC2 instance-type recommendations (via AWS instance type data and pricing) and is only implemented for AWS clusters. RunToolboxInstanceSelector retrieves the cluster and rejects any cluster whose cloudProvider is not kops.CloudProviderAWS with this error.

Source

Thrown at cmd/kops/toolbox_instance-selector.go:242

	commandline.IntFlag(maxResults, nil, &maxResultsDefault, "Maximum number of instance types to return back")
	commandline.BoolFlag(dryRun, nil, &dryRunDefault, "Only print the object that would be created, without creating it. This flag can be used to create a cluster YAML or JSON manifest.")
	commandline.StringFlag(output, commandline.StringMe("o"), &outputDefault, "Output format. One of json or yaml. Used with the --dry-run flag.", nil)
	commandline.Command.RegisterFlagCompletionFunc(output, func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
		return []string{"json", "yaml"}, cobra.ShellCompDirectiveNoFileComp
	})

	return commandline.Command
}

// RunToolboxInstanceSelector executes the instance-selector tool to create instance groups with declarative resource specifications
func RunToolboxInstanceSelector(ctx context.Context, f commandutils.Factory, out io.Writer, commandline *cli.CommandLineInterface, options *InstanceSelectorOptions) error {
	clientset, cluster, channel, err := retrieveClusterRefs(ctx, f, options.ClusterName)
	if err != nil {
		return err
	}

	if cluster.GetCloudProvider() != kops.CloudProviderAWS {
		return fmt.Errorf("cannot select instance types from non-aws cluster")
	}

	firstClusterSubnet := strings.ReplaceAll(cluster.Spec.Networking.Subnets[0].Name, "utility-", "")
	region := firstClusterSubnet[:len(firstClusterSubnet)-1]

	igSubnets := []string{}
	for _, clusterSubnet := range cluster.Spec.Networking.Subnets {
		igSubnets = append(igSubnets, clusterSubnet.Name)
	}

	if commandline.Flags[subnets] != nil {
		userSubnets := *commandline.StringSliceMe(commandline.Flags[subnets])
		dryRun := *commandline.BoolMe(commandline.Flags[dryRun])
		err := validateUserSubnets(userSubnets, cluster.Spec.Networking.Subnets)
		if err != nil && !dryRun {
			return err
		}
		igSubnets = userSubnets

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Point --name at an AWS cluster
  2. For other clouds, size instances with the provider's own tooling (e.g. GCE machine recommendations)
  3. Check the cluster spec: kops get cluster <name> -o yaml | grep cloudProvider

Example fix

// before
kops toolbox instance-selector nodes --name gcp-cluster.example.com
// error: cannot select instance types from non-aws cluster
// after — target an AWS cluster
kops toolbox instance-selector nodes --name aws-cluster.k8s.local
Defensive patterns

Strategy: validation

Validate before calling

PROVIDER=$(kops get cluster "$CLUSTER" -o json | jq -r '.spec.cloudProvider.type // .spec.cloudProvider')
if [ "$PROVIDER" != "aws" ]; then
  echo "instance-selector requires an AWS cluster (got: $PROVIDER)" >&2
  exit 3
fi

Prevention

When it happens

Trigger: Running `kops toolbox instance-selector` against a cluster whose spec has cloudProvider set to gce, hetzner, openstack, digitalocean, azure, etc.

Common situations: Mixed-fleet operators running an AWS-oriented workflow against a GCP/Hetzner cluster; copying commands from AWS-focused docs; a mis-set cloudProvider in the cluster spec.

Related errors


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