func()

in pkg/cloudprovider/aws/instancetypes.go [63:95]


func (p *InstanceTypeProvider) Get(ctx context.Context, provider *v1alpha1.AWS) ([]cloudprovider.InstanceType, error) {
	// Get InstanceTypes from EC2
	instanceTypes, err := p.getInstanceTypes(ctx)
	if err != nil {
		return nil, err
	}
	// Get Viable AZs from subnets
	subnets, err := p.subnetProvider.Get(ctx, provider)
	if err != nil {
		return nil, err
	}
	subnetZones := sets.NewString()
	for _, subnet := range subnets {
		subnetZones.Insert(aws.StringValue(subnet.AvailabilityZone))
	}
	// Get Viable EC2 Purchase offerings
	instanceTypeZones, err := p.getInstanceTypeZones(ctx)
	if err != nil {
		return nil, err
	}
	result := []cloudprovider.InstanceType{}
	for _, instanceType := range instanceTypes {
		offerings := p.createOfferings(instanceType, subnetZones, instanceTypeZones[instanceType.Name()])
		if len(offerings) > 0 {
			instanceType.AvailableOfferings = offerings
			result = append(result, instanceType)
		}
		if !injection.GetOptions(ctx).AWSENILimitedPodDensity {
			instanceType.MaxPods = ptr.Int32(110)
		}
	}
	return result, nil
}