amifamily

package
v1.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 4, 2024 License: Apache-2.0 Imports: 26 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// AMIVersionLatest is the version used in EKS aliases to represent the latest version. This maps to different
	// values in the SSM path, depending on the AMI type (e.g. "recommended" for AL2/AL2023)).
	AMIVersionLatest = "latest"
)

Variables

View Source
var DefaultEBS = v1.BlockDevice{
	Encrypted:  aws.Bool(true),
	VolumeType: aws.String(ec2.VolumeTypeGp3),
	VolumeSize: lo.ToPtr(resource.MustParse("20Gi")),
}

Functions

func MapToInstanceTypes added in v0.37.0

func MapToInstanceTypes(instanceTypes []*cloudprovider.InstanceType, amis []v1.AMI) map[string][]*cloudprovider.InstanceType

MapToInstanceTypes returns a map of AMIIDs that are the most recent on creationDate to compatible instancetypes

Types

type AL2

type AL2 struct {
	DefaultFamily
	*Options
}

func (AL2) DefaultBlockDeviceMappings

func (a AL2) DefaultBlockDeviceMappings() []*v1.BlockDeviceMapping

DefaultBlockDeviceMappings returns the default block device mappings for the AMI Family

func (AL2) DescribeImageQuery added in v1.0.0

func (a AL2) DescribeImageQuery(ctx context.Context, ssmProvider ssm.Provider, k8sVersion string, amiVersion string) (DescribeImageQuery, error)

func (AL2) EphemeralBlockDevice

func (a AL2) EphemeralBlockDevice() *string

func (AL2) UserData

func (a AL2) UserData(kubeletConfig *v1.KubeletConfiguration, taints []corev1.Taint, labels map[string]string, caBundle *string, _ []*cloudprovider.InstanceType, customUserData *string, instanceStorePolicy *v1.InstanceStorePolicy) bootstrap.Bootstrapper

UserData returns the exact same string for equivalent input, even if elements of those inputs are in differing orders, guaranteeing it won't cause spurious hash differences. AL2 userdata also works on Ubuntu

type AL2023 added in v0.35.0

type AL2023 struct {
	DefaultFamily
	*Options
}

func (AL2023) DefaultBlockDeviceMappings added in v0.35.0

func (a AL2023) DefaultBlockDeviceMappings() []*v1.BlockDeviceMapping

DefaultBlockDeviceMappings returns the default block device mappings for the AMI Family

func (AL2023) DescribeImageQuery added in v1.0.0

func (a AL2023) DescribeImageQuery(ctx context.Context, ssmProvider ssm.Provider, k8sVersion string, amiVersion string) (DescribeImageQuery, error)

func (AL2023) EphemeralBlockDevice added in v0.35.0

func (a AL2023) EphemeralBlockDevice() *string

func (AL2023) UserData added in v0.35.0

func (a AL2023) UserData(kubeletConfig *v1.KubeletConfiguration, taints []corev1.Taint, labels map[string]string, caBundle *string, _ []*cloudprovider.InstanceType, customUserData *string, instanceStorePolicy *v1.InstanceStorePolicy) bootstrap.Bootstrapper

type AMI

type AMI struct {
	Name         string
	AmiID        string
	CreationDate string
	Requirements scheduling.Requirements
}

type AMIFamily

type AMIFamily interface {
	DescribeImageQuery(ctx context.Context, ssmProvider ssm.Provider, k8sVersion string, amiVersion string) (DescribeImageQuery, error)
	UserData(kubeletConfig *v1.KubeletConfiguration, taints []corev1.Taint, labels map[string]string, caBundle *string, instanceTypes []*cloudprovider.InstanceType, customUserData *string, instanceStorePolicy *v1.InstanceStorePolicy) bootstrap.Bootstrapper
	DefaultBlockDeviceMappings() []*v1.BlockDeviceMapping
	DefaultMetadataOptions() *v1.MetadataOptions
	EphemeralBlockDevice() *string
	FeatureFlags() FeatureFlags
}

AMIFamily can be implemented to override the default logic for generating dynamic launch template parameters

func GetAMIFamily

func GetAMIFamily(amiFamily string, options *Options) AMIFamily

type AMIs

type AMIs []AMI

func (AMIs) Sort

func (a AMIs) Sort()

Sort orders the AMIs by creation date in descending order. If creation date is nil or two AMIs have the same creation date, the AMIs will be sorted by ID, which is guaranteed to be unique, in ascending order.

type Bottlerocket

type Bottlerocket struct {
	DefaultFamily
	*Options
}

func (Bottlerocket) DefaultBlockDeviceMappings

func (b Bottlerocket) DefaultBlockDeviceMappings() []*v1.BlockDeviceMapping

DefaultBlockDeviceMappings returns the default block device mappings for the AMI Family

func (Bottlerocket) DescribeImageQuery added in v1.0.0

func (b Bottlerocket) DescribeImageQuery(ctx context.Context, ssmProvider ssm.Provider, k8sVersion string, amiVersion string) (DescribeImageQuery, error)

func (Bottlerocket) EphemeralBlockDevice

func (b Bottlerocket) EphemeralBlockDevice() *string

func (Bottlerocket) FeatureFlags

func (b Bottlerocket) FeatureFlags() FeatureFlags

func (Bottlerocket) UserData

func (b Bottlerocket) UserData(kubeletConfig *v1.KubeletConfiguration, taints []corev1.Taint, labels map[string]string, caBundle *string, _ []*cloudprovider.InstanceType, customUserData *string, _ *v1.InstanceStorePolicy) bootstrap.Bootstrapper

UserData returns the default userdata script for the AMI Family

type Custom

type Custom struct {
	DefaultFamily
	*Options
}

func (Custom) DefaultBlockDeviceMappings

func (c Custom) DefaultBlockDeviceMappings() []*v1.BlockDeviceMapping

func (Custom) DescribeImageQuery added in v1.0.0

func (c Custom) DescribeImageQuery(_ context.Context, _ ssm.Provider, _ string, _ string) (DescribeImageQuery, error)

func (Custom) EphemeralBlockDevice

func (c Custom) EphemeralBlockDevice() *string

EphemeralBlockDevice is the block device that the pods on the node will use. For an AMI of a custom family, this is unknown to us.

func (Custom) UserData

UserData returns the default userdata script for the AMI Family

type DefaultAMIOutput

type DefaultAMIOutput struct {
	Query        string
	Requirements scheduling.Requirements
}

type DefaultFamily

type DefaultFamily struct{}

DefaultFamily provides default values for AMIFamilies that compose it

func (DefaultFamily) FeatureFlags

func (d DefaultFamily) FeatureFlags() FeatureFlags

type DefaultProvider added in v0.36.0

type DefaultProvider struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewDefaultProvider added in v0.36.0

func NewDefaultProvider(versionProvider version.Provider, ssmProvider ssm.Provider, ec2api ec2iface.EC2API, cache *cache.Cache) *DefaultProvider

func (*DefaultProvider) DescribeImageQueries added in v1.0.0

func (p *DefaultProvider) DescribeImageQueries(ctx context.Context, nodeClass *v1.EC2NodeClass) ([]DescribeImageQuery, error)

func (*DefaultProvider) List added in v0.37.0

func (p *DefaultProvider) List(ctx context.Context, nodeClass *v1.EC2NodeClass) (AMIs, error)

Get Returning a list of AMIs with its associated requirements

type DescribeImageQuery added in v1.0.0

type DescribeImageQuery struct {
	Filters []*ec2.Filter
	Owners  []string
	// KnownRequirements is a map from image IDs to a set of known requirements.
	// When discovering image IDs via SSM we know additional requirements which aren't surfaced by ec2:DescribeImage (e.g. GPU / Neuron compatibility)
	// Sometimes, an image may have multiple sets of known requirements. For example, the AL2 GPU AMI is compatible with both Neuron and Nvidia GPU
	// instances, which means we need a set of requirements for either instance type.
	KnownRequirements map[string][]scheduling.Requirements
}

func (DescribeImageQuery) DescribeImagesInput added in v1.0.0

func (q DescribeImageQuery) DescribeImagesInput() *ec2.DescribeImagesInput

func (DescribeImageQuery) RequirementsForImageWithArchitecture added in v1.0.0

func (q DescribeImageQuery) RequirementsForImageWithArchitecture(image string, arch string) []scheduling.Requirements

type FeatureFlags

type FeatureFlags struct {
	UsesENILimitedMemoryOverhead bool
	PodsPerCoreEnabled           bool
	EvictionSoftEnabled          bool
	SupportsENILimitedPodDensity bool
}

FeatureFlags describes whether the features below are enabled for a given AMIFamily

type LaunchTemplate

type LaunchTemplate struct {
	*Options
	UserData            bootstrap.Bootstrapper
	BlockDeviceMappings []*v1.BlockDeviceMapping
	MetadataOptions     *v1.MetadataOptions
	AMIID               string
	InstanceTypes       []*cloudprovider.InstanceType `hash:"ignore"`
	DetailedMonitoring  bool
	EFACount            int
	CapacityType        string
}

LaunchTemplate holds the dynamically generated launch template parameters

type Options

type Options struct {
	ClusterName         string
	ClusterEndpoint     string
	ClusterCIDR         *string
	InstanceProfile     string
	CABundle            *string `hash:"ignore"`
	InstanceStorePolicy *v1.InstanceStorePolicy
	// Level-triggered fields that may change out of sync.
	SecurityGroups           []v1.SecurityGroup
	Tags                     map[string]string
	Labels                   map[string]string `hash:"ignore"`
	KubeDNSIP                net.IP
	AssociatePublicIPAddress *bool
	NodeClassName            string
}

Options define the static launch template parameters

func (Options) DefaultMetadataOptions

func (o Options) DefaultMetadataOptions() *v1.MetadataOptions

type Provider

type Provider interface {
	List(ctx context.Context, nodeClass *v1.EC2NodeClass) (AMIs, error)
}

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver is able to fill-in dynamic launch template parameters

func NewResolver added in v0.36.0

func NewResolver(amiProvider Provider) *Resolver

NewResolver constructs a new launch template Resolver

func (Resolver) Resolve

func (r Resolver) Resolve(nodeClass *v1.EC2NodeClass, nodeClaim *karpv1.NodeClaim, instanceTypes []*cloudprovider.InstanceType, capacityType string, options *Options) ([]*LaunchTemplate, error)

Resolve generates launch templates using the static options and dynamically generates launch template parameters. Multiple ResolvedTemplates are returned based on the instanceTypes passed in to support special AMIs for certain instance types like GPUs.

type Ubuntu

type Ubuntu struct {
	DefaultFamily
	*Options
}

func (Ubuntu) DefaultAMIs

func (u Ubuntu) DefaultAMIs(version string) []DefaultAMIOutput

DefaultAMIs returns the AMI name, and Requirements, with an SSM query TODO: This should be removed at v1.1.0

func (Ubuntu) DefaultBlockDeviceMappings

func (u Ubuntu) DefaultBlockDeviceMappings() []*v1.BlockDeviceMapping

DefaultBlockDeviceMappings returns the default block device mappings for the AMI Family

func (Ubuntu) EphemeralBlockDevice

func (u Ubuntu) EphemeralBlockDevice() *string

func (Ubuntu) UserData

func (u Ubuntu) UserData(kubeletConfig *v1.KubeletConfiguration, taints []corev1.Taint, labels map[string]string, caBundle *string, _ []*cloudprovider.InstanceType, customUserData *string, _ *v1.InstanceStorePolicy) bootstrap.Bootstrapper

UserData returns the default userdata script for the AMI Family

type Variant added in v1.0.0

type Variant string
var (
	VariantStandard Variant = "standard"
	VariantNvidia   Variant = "nvidia"
	VariantNeuron   Variant = "neuron"
)

func NewVariant added in v1.0.0

func NewVariant(v string) (Variant, error)

func (Variant) Requirements added in v1.0.0

func (v Variant) Requirements() scheduling.Requirements

type Windows

type Windows struct {
	DefaultFamily
	*Options
	// Version is the major version of Windows Server (2019 or 2022).
	// Only the core version of each version is supported by Karpenter, so this field only indicates the year.
	Version string
	// Build is a specific build code associated with the Version
	Build string
}

func (Windows) DefaultBlockDeviceMappings

func (w Windows) DefaultBlockDeviceMappings() []*v1.BlockDeviceMapping

DefaultBlockDeviceMappings returns the default block device mappings for the AMI Family

func (Windows) DescribeImageQuery added in v1.0.0

func (w Windows) DescribeImageQuery(ctx context.Context, ssmProvider ssm.Provider, k8sVersion string, amiVersion string) (DescribeImageQuery, error)

func (Windows) EphemeralBlockDevice

func (w Windows) EphemeralBlockDevice() *string

func (Windows) FeatureFlags

func (w Windows) FeatureFlags() FeatureFlags

func (Windows) UserData

func (w Windows) UserData(kubeletConfig *v1.KubeletConfiguration, taints []corev1.Taint, labels map[string]string, caBundle *string, _ []*cloudprovider.InstanceType, customUserData *string, _ *v1.InstanceStorePolicy) bootstrap.Bootstrapper

UserData returns the default userdata script for the AMI Family

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL