awsup

package
v1.27.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2023 License: Apache-2.0 Imports: 62 Imported by: 664

Documentation

Index

Constants

View Source
const (
	DescribeTagsMaxAttempts   = 120
	DescribeTagsRetryInterval = 2 * time.Second
	DescribeTagsLogInterval   = 10 // this is in "retry intervals"
)
View Source
const (
	CreateTagsMaxAttempts   = 120
	CreateTagsRetryInterval = 2 * time.Second
	CreateTagsLogInterval   = 10 // this is in "retry intervals"
)
View Source
const (
	DeleteTagsMaxAttempts   = 120
	DeleteTagsRetryInterval = 2 * time.Second
	DeleteTagsLogInterval   = 10 // this is in "retry intervals"
)
View Source
const (
	TagClusterName           = "KubernetesCluster"
	TagNameRolePrefix        = "k8s.io/role/"
	TagNameEtcdClusterPrefix = "k8s.io/etcd/"
)
View Source
const (
	WellKnownAccountAmazonLinux2 = "137112412989"
	WellKnownAccountDebian       = "136693071363"
	WellKnownAccountFlatcar      = "075585003325"
	WellKnownAccountRedhat       = "309956199498"
	WellKnownAccountUbuntu       = "099720109477"
)
View Source
const AWSAuthenticationTokenPrefix = "x-aws-sts "
View Source
const AWSErrCodeInvalidAction = "InvalidAction"

AWSErrCodeInvalidAction is returned in AWS partitions that don't support certain actions

View Source
const ClientMaxRetries = 13

By default, aws-sdk-go only retries 3 times, which doesn't give much time for exponential backoff to work for serious issues. At 13 retries, we'll try a given request for up to ~6m with exponential backoff along the way.

View Source
const TagNameClusterOwnershipPrefix = "kubernetes.io/cluster/"

TagNameClusterOwnershipPrefix is the AWS tag used for ownership

View Source
const TagNameKopsRole = "kubernetes.io/kops/role"

TagNameKopsRole is the AWS tag used to identify the role an object plays for a cluster

View Source
const TagRoleControlPlane = "control-plane"
View Source
const TagRoleMaster = "master"

Variables

This section is empty.

Functions

func AWSErrorCode

func AWSErrorCode(err error) string

AWSErrorCode returns the aws error code, if it is an awserr.Error, otherwise ""

func AWSErrorMessage

func AWSErrorMessage(err error) string

AWSErrorMessage returns the aws error message, if it is an awserr.Error, otherwise ""

func EC2TagSpecification added in v1.19.0

func EC2TagSpecification(resourceType string, tags map[string]string) []*ec2.TagSpecification

EC2TagSpecification converts a map of tags to an EC2 TagSpecification

func ELBv2Tags added in v1.21.0

func ELBv2Tags(tags map[string]string) []*elbv2.Tag

ELBv2Tags converts a map of tags to ELBv2 Tags

func FindASGTag

func FindASGTag(tags []*autoscaling.TagDescription, key string) (string, bool)

FindASGTag find the value of the tag with the specified key

func FindAutoscalingGroups added in v1.10.0

func FindAutoscalingGroups(c AWSCloud, tags map[string]string) ([]*autoscaling.Group, error)

FindAutoscalingGroups finds autoscaling groups matching the specified tags This isn't entirely trivial because autoscaling doesn't let us filter with as much precision as we would like

func FindEC2Tag

func FindEC2Tag(tags []*ec2.Tag, key string) (string, bool)

FindEC2Tag find the value of the tag with the specified key

func FindELBTag

func FindELBTag(tags []*elb.Tag, key string) (string, bool)

FindELBTag find the value of the tag with the specified key

func FindELBV2Tag added in v1.11.0

func FindELBV2Tag(tags []*elbv2.Tag, key string) (string, bool)

FindELBV2Tag find the value of the tag with the specified key

func FindRegion added in v1.10.0

func FindRegion(cluster *kops.Cluster) (string, error)

FindRegion determines the region from the zones specified in the cluster

func GetClusterName40 added in v1.21.2

func GetClusterName40(cluster string) string

GetClusterName40 will attempt to calculate a meaningful cluster name with a max length of 40

func GetInstanceCertificateNames added in v1.21.3

func GetInstanceCertificateNames(instances *ec2.DescribeInstancesOutput, useInstanceIDForNodeName bool) (addrs []string, err error)

GetInstanceCertificateNames returns the instance hostname and addresses that should go into certificates. The first value is the node name and any additional values are the DNS name and IP addresses.

func GetResourceName32 added in v1.18.3

func GetResourceName32(cluster string, prefix string) string

GetResourceName32 will attempt to calculate a meaningful name for a resource given a prefix Will never return a string longer than 32 chars

func GetRolesInInstanceProfile added in v1.19.1

func GetRolesInInstanceProfile(c AWSCloud, profileName string) ([]string, error)

GetRolesInInstanceProfile return role names which are associated with the instance profile specified by profileName.

func GetTargetGroupNameFromARN added in v1.18.3

func GetTargetGroupNameFromARN(targetGroupARN string) (string, error)

GetTargetGroupNameFromARN will attempt to parse a target group ARN and return its name

func NewAWSAuthenticator added in v1.19.0

func NewAWSAuthenticator(region string) (bootstrap.Authenticator, error)

func NewAWSVerifier added in v1.19.0

func NewAWSVerifier(opt *AWSVerifierOptions) (bootstrap.Verifier, error)

func NewEC2Filter

func NewEC2Filter(name string, values ...string) *ec2.Filter

func RegionFromMetadata added in v1.21.0

func RegionFromMetadata(ctx context.Context) (string, error)

RegionFromMetadata returns the current region from the aws metdata

func ResetAWSCloudInstances added in v1.27.0

func ResetAWSCloudInstances()

func ValidateRegion

func ValidateRegion(region string) error

ValidateRegion checks that an AWS region name is valid

func ValidateZones

func ValidateZones(zones []string, cloud AWSCloud) error

ValidateZones checks that every zone in the sliced passed is recognized

Types

type AWSAPITarget

type AWSAPITarget struct {
	Cloud AWSCloud
}

func NewAWSAPITarget

func NewAWSAPITarget(cloud AWSCloud) *AWSAPITarget

func (*AWSAPITarget) AddAWSTags

func (t *AWSAPITarget) AddAWSTags(id string, expected map[string]string) error

func (*AWSAPITarget) AddELBTags

func (t *AWSAPITarget) AddELBTags(loadBalancerName string, expected map[string]string) error

func (*AWSAPITarget) AddELBV2Tags added in v1.19.0

func (t *AWSAPITarget) AddELBV2Tags(ResourceArn string, expected map[string]string) error

func (*AWSAPITarget) CreateTags added in v1.19.0

func (t *AWSAPITarget) CreateTags(id string, tags map[string]string) error

func (*AWSAPITarget) DefaultCheckExisting added in v1.26.0

func (t *AWSAPITarget) DefaultCheckExisting() bool

func (*AWSAPITarget) DeleteTags added in v1.10.0

func (t *AWSAPITarget) DeleteTags(id string, tags map[string]string) error

func (*AWSAPITarget) Finish

func (t *AWSAPITarget) Finish(taskMap map[string]fi.CloudupTask) error

func (*AWSAPITarget) GetTags added in v1.19.0

func (t *AWSAPITarget) GetTags(id string) (map[string]string, error)

func (*AWSAPITarget) ProcessDeletions added in v1.10.0

func (t *AWSAPITarget) ProcessDeletions() bool

func (*AWSAPITarget) RemoveELBTags added in v1.15.1

func (t *AWSAPITarget) RemoveELBTags(loadBalancerName string, expected map[string]string) error

func (*AWSAPITarget) RemoveELBV2Tags added in v1.19.0

func (t *AWSAPITarget) RemoveELBV2Tags(ResourceArn string, expected map[string]string) error

func (*AWSAPITarget) UpdateTags added in v1.19.0

func (t *AWSAPITarget) UpdateTags(id string, tags map[string]string) error

func (*AWSAPITarget) WaitForInstanceRunning

func (t *AWSAPITarget) WaitForInstanceRunning(instanceID string) error

type AWSCloud

type AWSCloud interface {
	fi.Cloud
	Session() (*session.Session, error)
	EC2() ec2iface.EC2API
	IAM() iamiface.IAMAPI
	ELB() elbiface.ELBAPI
	ELBV2() elbv2iface.ELBV2API
	Autoscaling() autoscalingiface.AutoScalingAPI
	Route53() route53iface.Route53API
	Spotinst() spotinst.Cloud
	SQS() sqsiface.SQSAPI
	EventBridge() eventbridgeiface.EventBridgeAPI
	SSM() ssmiface.SSMAPI

	// TODO: Document and rationalize these tags/filters methods
	AddTags(name *string, tags map[string]string)
	BuildFilters(name *string) []*ec2.Filter
	BuildTags(name *string) map[string]string
	Tags() map[string]string

	// GetTags will fetch the tags for the specified resource, retrying (up to MaxDescribeTagsAttempts) if it hits an eventual-consistency type error
	GetTags(resourceId string) (map[string]string, error)
	// CreateTags will add/modify tags to the specified resource, retrying up to MaxCreateTagsAttempts times if it hits an eventual-consistency type error
	CreateTags(resourceId string, tags map[string]string) error
	// DeleteTags will remove tags from the specified resource, retrying up to MaxCreateTagsAttempts times if it hits an eventual-consistency type error
	DeleteTags(resourceId string, tags map[string]string) error
	// UpdateTags will update tags of the specified resource to match tags, using getTags(), createTags() and deleteTags()
	UpdateTags(resourceId string, tags map[string]string) error
	AddAWSTags(id string, expected map[string]string) error
	GetELBTags(loadBalancerName string) (map[string]string, error)
	GetELBV2Tags(ResourceArn string) (map[string]string, error)

	// CreateELBTags will add tags to the specified loadBalancer, retrying up to MaxCreateTagsAttempts times if it hits an eventual-consistency type error
	CreateELBTags(loadBalancerName string, tags map[string]string) error
	CreateELBV2Tags(ResourceArn string, tags map[string]string) error
	// RemoveELBTags will remove tags from the specified loadBalancer, retrying up to MaxCreateTagsAttempts times if it hits an eventual-consistency type error
	RemoveELBTags(loadBalancerName string, tags map[string]string) error
	RemoveELBV2Tags(ResourceArn string, tags map[string]string) error
	FindELBByNameTag(findNameTag string) (*elb.LoadBalancerDescription, error)
	DescribeELBTags(loadBalancerNames []string) (map[string][]*elb.Tag, error)
	FindELBV2ByNameTag(findNameTag string) (*elbv2.LoadBalancer, error)
	DescribeELBV2Tags(loadBalancerNames []string) (map[string][]*elbv2.Tag, error)
	FindELBV2NetworkInterfacesByName(vpcID string, loadBalancerName string) ([]*ec2.NetworkInterface, error)

	// DescribeInstance is a helper that queries for the specified instance by id
	DescribeInstance(instanceID string) (*ec2.Instance, error)

	// DescribeVPC is a helper that queries for the specified vpc by id
	DescribeVPC(vpcID string) (*ec2.Vpc, error)
	DescribeAvailabilityZones() ([]*ec2.AvailabilityZone, error)

	// ResolveImage finds an AMI image based on the given name.
	// The name can be one of:
	// `ami-...` in which case it is presumed to be an id
	// owner/name in which case we find the image with the specified name, owned by owner
	// name in which case we find the image with the specified name, with the current owner
	ResolveImage(name string) (*ec2.Image, error)

	// WithTags created a copy of AWSCloud with the specified default-tags bound
	WithTags(tags map[string]string) AWSCloud

	// DefaultInstanceType determines a suitable instance type for the specified instance group
	DefaultInstanceType(cluster *kops.Cluster, ig *kops.InstanceGroup) (string, error)

	// DescribeInstanceType calls ec2.DescribeInstanceType to get information for a particular instance type
	DescribeInstanceType(instanceType string) (*ec2.InstanceTypeInfo, error)

	// AccountInfo returns the AWS account ID and AWS partition that we are deploying into
	AccountInfo() (string, string, error)
}

func NewAWSCloud

func NewAWSCloud(region string, tags map[string]string) (AWSCloud, error)

type AWSMachineTypeInfo

type AWSMachineTypeInfo struct {
	Name              string
	MemoryGB          float32
	Cores             int
	EphemeralDisks    []int
	GPU               bool
	MaxPods           int
	InstanceENIs      int
	InstanceIPsPerENI int
}

func GetMachineTypeInfo

func GetMachineTypeInfo(c AWSCloud, machineType string) (*AWSMachineTypeInfo, error)

func (*AWSMachineTypeInfo) EphemeralDevices

func (m *AWSMachineTypeInfo) EphemeralDevices() []*EphemeralDevice

type AWSVerifierOptions added in v1.19.0

type AWSVerifierOptions struct {
	// NodesRoles are the IAM roles that worker nodes are permitted to have.
	NodesRoles []string `json:"nodesRoles"`
	// Region is the AWS region of the cluster.
	Region string
}

type EphemeralDevice

type EphemeralDevice struct {
	DeviceName  string
	VirtualName string
	SizeGB      int
}

type GetCallerIdentityResponse added in v1.19.0

type GetCallerIdentityResponse struct {
	XMLName                 xml.Name                  `xml:"GetCallerIdentityResponse"`
	GetCallerIdentityResult []GetCallerIdentityResult `xml:"GetCallerIdentityResult"`
	ResponseMetadata        []ResponseMetadata        `xml:"ResponseMetadata"`
}

type GetCallerIdentityResult added in v1.19.0

type GetCallerIdentityResult struct {
	Arn     string `xml:"Arn"`
	UserId  string `xml:"UserId"`
	Account string `xml:"Account"`
}

type LoggingRetryer added in v1.10.0

type LoggingRetryer struct {
	client.DefaultRetryer
}

LoggingRetryer adds some logging when we are retrying, so we have some idea what is happening Right now it is very basic - e.g. it only logs when we retry (so doesn't log when we fail due to too many retries)

func (LoggingRetryer) RetryRules added in v1.10.0

func (l LoggingRetryer) RetryRules(r *request.Request) time.Duration

type MockAWSCloud

type MockAWSCloud struct {
	MockCloud
	// contains filtered or unexported fields
}

func BuildMockAWSCloud added in v1.10.0

func BuildMockAWSCloud(region string, zoneLetters string) *MockAWSCloud

func InstallMockAWSCloud

func InstallMockAWSCloud(region string, zoneLetters string) *MockAWSCloud

func (*MockAWSCloud) AccountInfo added in v1.19.0

func (c *MockAWSCloud) AccountInfo() (string, string, error)

AccountInfo returns the AWS account ID and AWS partition that we are deploying into

func (*MockAWSCloud) AddAWSTags

func (c *MockAWSCloud) AddAWSTags(id string, expected map[string]string) error

func (*MockAWSCloud) AddTags

func (c *MockAWSCloud) AddTags(name *string, tags map[string]string)

func (*MockAWSCloud) Autoscaling

func (c *MockAWSCloud) Autoscaling() autoscalingiface.AutoScalingAPI

func (*MockAWSCloud) BuildFilters

func (c *MockAWSCloud) BuildFilters(name *string) []*ec2.Filter

func (*MockAWSCloud) BuildTags

func (c *MockAWSCloud) BuildTags(name *string) map[string]string

func (*MockAWSCloud) CreateELBTags

func (c *MockAWSCloud) CreateELBTags(loadBalancerName string, tags map[string]string) error

func (*MockAWSCloud) CreateELBV2Tags added in v1.11.0

func (c *MockAWSCloud) CreateELBV2Tags(ResourceArn string, tags map[string]string) error

func (*MockAWSCloud) CreateTags

func (c *MockAWSCloud) CreateTags(resourceId string, tags map[string]string) error

func (*MockAWSCloud) DefaultInstanceType added in v1.10.0

func (c *MockAWSCloud) DefaultInstanceType(cluster *kops.Cluster, ig *kops.InstanceGroup) (string, error)

DefaultInstanceType determines an instance type for the specified cluster & instance group

func (*MockAWSCloud) DeleteGroup added in v1.10.0

func (*MockAWSCloud) DeleteInstance added in v1.10.0

func (c *MockAWSCloud) DeleteInstance(i *cloudinstances.CloudInstance) error

func (*MockAWSCloud) DeleteTags added in v1.10.0

func (c *MockAWSCloud) DeleteTags(id string, tags map[string]string) error

func (*MockAWSCloud) DeregisterInstance added in v1.24.0

func (c *MockAWSCloud) DeregisterInstance(i *cloudinstances.CloudInstance) error

func (*MockAWSCloud) DescribeAvailabilityZones

func (c *MockAWSCloud) DescribeAvailabilityZones() ([]*ec2.AvailabilityZone, error)

func (*MockAWSCloud) DescribeELBTags added in v1.21.3

func (c *MockAWSCloud) DescribeELBTags(loadBalancerNames []string) (map[string][]*elb.Tag, error)

func (*MockAWSCloud) DescribeELBV2Tags added in v1.21.3

func (c *MockAWSCloud) DescribeELBV2Tags(loadBalancerArns []string) (map[string][]*elbv2.Tag, error)

func (*MockAWSCloud) DescribeInstance

func (c *MockAWSCloud) DescribeInstance(instanceID string) (*ec2.Instance, error)

func (*MockAWSCloud) DescribeInstanceType added in v1.19.0

func (c *MockAWSCloud) DescribeInstanceType(instanceType string) (*ec2.InstanceTypeInfo, error)

DescribeInstanceType calls ec2.DescribeInstanceType to get information for a particular instance type

func (*MockAWSCloud) DescribeVPC

func (c *MockAWSCloud) DescribeVPC(vpcID string) (*ec2.Vpc, error)

func (*MockAWSCloud) DetachInstance added in v1.18.0

func (c *MockAWSCloud) DetachInstance(i *cloudinstances.CloudInstance) error

func (*MockAWSCloud) EC2

func (c *MockAWSCloud) EC2() ec2iface.EC2API

func (*MockAWSCloud) ELB

func (c *MockAWSCloud) ELB() elbiface.ELBAPI

func (*MockAWSCloud) ELBV2 added in v1.11.0

func (c *MockAWSCloud) ELBV2() elbv2iface.ELBV2API

func (*MockAWSCloud) EventBridge added in v1.21.0

func (c *MockAWSCloud) EventBridge() eventbridgeiface.EventBridgeAPI

func (*MockAWSCloud) FindClusterStatus added in v1.10.0

func (c *MockAWSCloud) FindClusterStatus(cluster *kops.Cluster) (*kops.ClusterStatus, error)

FindEtcdStatus discovers the status of the cluster, by looking for the tagged etcd volumes

func (*MockAWSCloud) FindELBByNameTag added in v1.21.3

func (c *MockAWSCloud) FindELBByNameTag(findNameTag string) (*elb.LoadBalancerDescription, error)

func (*MockAWSCloud) FindELBV2ByNameTag added in v1.21.3

func (c *MockAWSCloud) FindELBV2ByNameTag(findNameTag string) (*elbv2.LoadBalancer, error)

func (*MockAWSCloud) FindELBV2NetworkInterfacesByName added in v1.26.0

func (c *MockAWSCloud) FindELBV2NetworkInterfacesByName(vpcID, loadBalancerName string) ([]*ec2.NetworkInterface, error)

func (*MockAWSCloud) FindVPCInfo added in v1.10.0

func (c *MockAWSCloud) FindVPCInfo(id string) (*fi.VPCInfo, error)

func (*MockAWSCloud) GetApiIngressStatus added in v1.21.3

func (c *MockAWSCloud) GetApiIngressStatus(cluster *kops.Cluster) ([]fi.ApiIngressStatus, error)

func (*MockAWSCloud) GetCloudGroups added in v1.10.0

func (c *MockAWSCloud) GetCloudGroups(cluster *kops.Cluster, instancegroups []*kops.InstanceGroup, warnUnmatched bool, nodes []v1.Node) (map[string]*cloudinstances.CloudInstanceGroup, error)

func (*MockAWSCloud) GetELBTags

func (c *MockAWSCloud) GetELBTags(loadBalancerName string) (map[string]string, error)

func (*MockAWSCloud) GetELBV2Tags added in v1.11.0

func (c *MockAWSCloud) GetELBV2Tags(ResourceArn string) (map[string]string, error)

func (*MockAWSCloud) GetTags

func (c *MockAWSCloud) GetTags(resourceID string) (map[string]string, error)

func (*MockAWSCloud) IAM

func (c *MockAWSCloud) IAM() iamiface.IAMAPI

func (*MockAWSCloud) Region

func (c *MockAWSCloud) Region() string

func (*MockAWSCloud) RemoveELBTags added in v1.15.1

func (c *MockAWSCloud) RemoveELBTags(loadBalancerName string, tags map[string]string) error

func (*MockAWSCloud) RemoveELBV2Tags added in v1.19.0

func (c *MockAWSCloud) RemoveELBV2Tags(ResourceArn string, tags map[string]string) error

func (*MockAWSCloud) ResolveImage

func (c *MockAWSCloud) ResolveImage(name string) (*ec2.Image, error)

func (*MockAWSCloud) Route53

func (c *MockAWSCloud) Route53() route53iface.Route53API

func (*MockAWSCloud) SQS added in v1.21.0

func (c *MockAWSCloud) SQS() sqsiface.SQSAPI

func (*MockAWSCloud) SSM added in v1.25.3

func (c *MockAWSCloud) SSM() ssmiface.SSMAPI

func (*MockAWSCloud) Session added in v1.24.5

func (c *MockAWSCloud) Session() (*session.Session, error)

func (*MockAWSCloud) Spotinst added in v1.11.0

func (c *MockAWSCloud) Spotinst() spotinst.Cloud

func (*MockAWSCloud) Tags

func (c *MockAWSCloud) Tags() map[string]string

func (*MockAWSCloud) UpdateTags added in v1.19.0

func (c *MockAWSCloud) UpdateTags(id string, tags map[string]string) error

func (*MockAWSCloud) WithTags

func (c *MockAWSCloud) WithTags(tags map[string]string) AWSCloud

type MockCloud

type MockCloud struct {
	MockAutoscaling autoscalingiface.AutoScalingAPI
	MockEC2         ec2iface.EC2API
	MockIAM         iamiface.IAMAPI
	MockRoute53     route53iface.Route53API
	MockELB         elbiface.ELBAPI
	MockELBV2       elbv2iface.ELBV2API
	MockSpotinst    spotinst.Cloud
	MockSQS         sqsiface.SQSAPI
	MockEventBridge eventbridgeiface.EventBridgeAPI
	MockSSM         ssmiface.SSMAPI
}

func (*MockCloud) DNS

func (c *MockCloud) DNS() (dnsprovider.Interface, error)

func (*MockCloud) ProviderID

func (c *MockCloud) ProviderID() kops.CloudProviderID

type RegionDelayers added in v1.10.0

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

type RequestLogger added in v1.10.0

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

RequestLogger logs every AWS request

type ResponseMetadata added in v1.19.0

type ResponseMetadata struct {
	RequestId string `xml:"RequestId"`
}

Jump to

Keyboard shortcuts

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