kubernetes/kops · error
error initializing instance selector: %v
Error message
error initializing instance selector: %v
What it means
This wraps a failure from selector.New(ctx, cloud.Config()), which initializes the kOps instance-type selector by fetching EC2 instance type/price data (via the AWS pricing/EC2 APIs). If that discovery fails, the selector cannot be constructed and the command aborts.
Source
Thrown at cmd/kops/toolbox_instance-selector.go:276
return err
}
igSubnets = userSubnets
}
zones := []string{}
for _, igSubnet := range igSubnets {
zones = append(zones, strings.ReplaceAll(igSubnet, "utility-", ""))
}
tags := map[string]string{"KubernetesCluster": options.ClusterName}
cloud, err := awsup.NewAWSCloud(region, tags)
if err != nil {
return fmt.Errorf("error initializing AWS client: %v", err)
}
instanceSelector, err := selector.New(ctx, cloud.Config())
if err != nil {
return fmt.Errorf("error initializing instance selector: %v", err)
}
igCount := options.InstanceGroupCount
filters := getFilters(commandline, region, zones)
mutatedFilters := filters
if commandline.Flags[instanceGroupCount] != nil || filters.Flexible != nil {
if filters.VCpusToMemoryRatio == nil {
defaultStartRatio := float64(2.0)
mutatedFilters.VCpusToMemoryRatio = &defaultStartRatio
}
}
newInstanceGroups := []*kops.InstanceGroup{}
for i := 0; i < igCount; i++ {
igNameForRun := options.InstanceGroupName
if igCount != 1 {
igNameForRun = fmt.Sprintf("%s%d", options.InstanceGroupName, i+1)
}View on GitHub (pinned to 4c8573c808)
Solutions
- Grant the caller IAM permissions ec2:DescribeInstanceTypes and access to the AWS Pricing API.
- Retry after a short delay if throttling (RequestLimitExceeded) is the underlying cause.
- Confirm network access to ec2 and pricing endpoints for the region.
- Upgrade kOps if the region is newly launched and not yet known to this build.
Example fix
// IAM policy: allow selector initialization
// before
{"Effect": "Deny", "Action": ["ec2:Describe*"], "Resource": "*"}
// after
{"Effect": "Allow", "Action": ["ec2:DescribeInstanceTypes", "ec2:DescribeAvailabilityZones"], "Resource": "*"} Defensive patterns
Strategy: retry
Validate before calling
// Pre-flight IAM check // aws ec2 describe-instance-types --region $REGION --max-items 1 // exit code != 0 => permissions/network problem
Try / catch
var selectorInstance *selector.InstanceSelector
for attempt := 0; attempt < 3; attempt++ {
selectorInstance, err = selector.New(ctx, cloud.Config())
if err == nil { break }
time.Sleep(time.Duration(1<<attempt) * time.Second)
} Prevention
- Include ec2:DescribeInstanceTypes and pricing permissions in the operator role.
- Add exponential backoff around AWS metadata calls to survive throttling.
- Keep kOps updated for newly launched regions.
When it happens
Trigger: selector.New fails while enumerating EC2 instance types or pricing for the region: API throttling, denied permissions on ec2:DescribeInstanceTypes or pricing API, network failure, or unsupported/empty region data.
Common situations: IAM policy lacking ec2:DescribeInstanceTypes; running in a region where pricing data is unavailable; transient AWS API throttling on large accounts; network egress blocked to pricing endpoints.
Related errors
- cannot select instance types from non-aws cluster
- error finding matching instance types: %w
- error querying EC2 for user metadata for instance %q: %v
- error deleting tags on %v: %v
- DIGITALOCEAN_ACCESS_TOKEN is required
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/af681680e096eb1b.
Report an issue: GitHub.