Documentation ¶
Index ¶
- Constants
- Variables
- type APIs
- type EC2InstanceMetadataCache
- func (cache *EC2InstanceMetadataCache) AllocAllIPAddress(eniID string) error
- func (cache *EC2InstanceMetadataCache) AllocENI() (string, error)
- func (cache *EC2InstanceMetadataCache) AllocIPAddress(eniID string) error
- func (cache *EC2InstanceMetadataCache) DescribeENI(eniID string) ([]*ec2.NetworkInterfacePrivateIpAddress, *string, error)
- func (cache *EC2InstanceMetadataCache) FreeENI(eniName string) error
- func (cache *EC2InstanceMetadataCache) GetAttachedENIs() (eniList []ENIMetadata, err error)
- func (cache *EC2InstanceMetadataCache) GetENILimit() (int, error)
- func (cache *EC2InstanceMetadataCache) GetENIipLimit() (int64, error)
- func (cache *EC2InstanceMetadataCache) GetLocalIPv4() string
- func (cache *EC2InstanceMetadataCache) GetPrimaryENI() string
- func (cache *EC2InstanceMetadataCache) GetVPCIPv4CIDR() string
- type ENIMetadata
Constants ¶
const (
// UnknownInstanceType indicates that the instance type is not yet supported
UnknownInstanceType = "vpc ip resource(eni ip limit): unknown instance type"
)
Variables ¶
var InstanceENIsAvailable = map[string]int{
"c1.medium": 2,
"c1.xlarge": 4,
"c3.large": 3,
"c3.xlarge": 4,
"c3.2xlarge": 4,
"c3.4xlarge": 8,
"c3.8xlarge": 8,
"c4.large": 3,
"c4.xlarge": 4,
"c4.2xlarge": 4,
"c4.4xlarge": 8,
"c4.8xlarge": 8,
"cc2.8xlarge": 8,
"cg1.4xlarge": 8,
"cr1.8xlarge": 8,
"d2.xlarge": 4,
"d2.2xlarge": 4,
"d2.4xlarge": 8,
"d2.8xlarge": 8,
"f1.2xlarge": 4,
"f1.16xlarge": 8,
"g2.2xlarge": 4,
"g2.8xlarge": 8,
"g3.4xlarge": 8,
"g3.8xlarge": 8,
"g3.16xlarge": 15,
"hi1.4xlarge": 8,
"hs1.8xlarge": 8,
"i2.xlarge": 4,
"i2.2xlarge": 4,
"i2.4xlarge": 8,
"i2.8xlarge": 8,
"i3.large": 3,
"i3.xlarge": 4,
"i3.2xlarge": 4,
"i3.4xlarge": 8,
"i3.8xlarge": 8,
"i3.16xlarge": 15,
"m1.small": 2,
"m1.medium": 2,
"m1.large": 3,
"m1.xlarge": 4,
"m2.xlarge": 4,
"m2.2xlarge": 4,
"m2.4xlarge": 8,
"m3.medium": 2,
"m3.large": 3,
"m3.xlarge": 4,
"m3.2xlarge": 4,
"m4.large": 2,
"m4.xlarge": 4,
"m4.2xlarge": 4,
"m4.4xlarge": 8,
"m4.10xlarge": 8,
"m4.16xlarge": 8,
"p2.xlarge": 4,
"p2.8xlarge": 8,
"p2.16xlarge": 8,
"r3.large": 3,
"r3.xlarge": 4,
"r3.2xlarge": 4,
"r3.4xlarge": 8,
"r3.8xlarge": 8,
"r4.large": 3,
"r4.xlarge": 4,
"r4.2xlarge": 4,
"r4.4xlarge": 8,
"r4.8xlarge": 8,
"r4.16xlarge": 15,
"t1.micro": 2,
"t2.nano": 2,
"t2.micro": 2,
"t2.small": 2,
"t2.medium": 3,
"t2.large": 3,
"t2.xlarge": 3,
"t2.2xlarge": 3,
"x1.16xlarge": 8,
"x1.32xlarge": 8,
}
InstanceENIsAvailable contains a mapping of instance types to the number of ENIs available which is described at https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-eni.html#AvailableIpPerENI
var InstanceIPsAvailable = map[string]int64{
"c1.medium": 6,
"c1.xlarge": 15,
"c3.large": 10,
"c3.xlarge": 15,
"c3.2xlarge": 15,
"c3.4xlarge": 30,
"c3.8xlarge": 30,
"c4.large": 10,
"c4.xlarge": 15,
"c4.2xlarge": 15,
"c4.4xlarge": 30,
"c4.8xlarge": 30,
"cc2.8xlarge": 30,
"cg1.4xlarge": 30,
"cr1.8xlarge": 30,
"d2.xlarge": 15,
"d2.2xlarge": 15,
"d2.4xlarge": 30,
"d2.8xlarge": 30,
"f1.2xlarge": 15,
"f1.16xlarge": 50,
"g2.2xlarge": 15,
"g2.8xlarge": 30,
"g3.4xlarge": 30,
"g3.8xlarge": 30,
"g3.16xlarge": 50,
"hi1.4xlarge": 30,
"hs1.8xlarge": 30,
"i2.xlarge": 15,
"i2.2xlarge": 15,
"i2.4xlarge": 30,
"i2.8xlarge": 30,
"i3.large": 10,
"i3.xlarge": 15,
"i3.2xlarge": 15,
"i3.4xlarge": 30,
"i3.8xlarge": 30,
"i3.16xlarge": 50,
"m1.small": 4,
"m1.medium": 6,
"m1.large": 10,
"m1.xlarge": 15,
"m2.xlarge": 15,
"m2.2xlarge": 30,
"m2.4xlarge": 30,
"m3.medium": 6,
"m3.large": 10,
"m3.xlarge": 15,
"m3.2xlarge": 30,
"m4.large": 10,
"m4.xlarge": 15,
"m4.2xlarge": 15,
"m4.4xlarge": 30,
"m4.10xlarge": 30,
"m4.16xlarge": 30,
"p2.xlarge": 15,
"p2.8xlarge": 30,
"p2.16xlarge": 30,
"r3.large": 10,
"r3.xlarge": 15,
"r3.2xlarge": 15,
"r3.4xlarge": 30,
"r3.8xlarge": 30,
"r4.large": 10,
"r4.xlarge": 15,
"r4.2xlarge": 15,
"r4.4xlarge": 30,
"r4.8xlarge": 30,
"r4.16xlarge": 50,
"t1.micro": 2,
"t2.nano": 2,
"t2.micro": 2,
"t2.small": 4,
"t2.medium": 6,
"t2.large": 12,
"t2.xlarge": 15,
"t2.2xlarge": 15,
"x1.16xlarge": 30,
"x1.32xlarge": 30,
}
InstanceIPsAvailable contains a mapping of instance types to the number of IPs per ENI https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-eni.html#AvailableIpPerENI
Functions ¶
This section is empty.
Types ¶
type APIs ¶
type APIs interface { // AllocENI creates an eni and attaches it to instance AllocENI() (eni string, err error) // FreeENI detaches eni interface and deletes it FreeENI(eniName string) error // GetAttachedENIs retrieves eni information from instance metadata service GetAttachedENIs() (eniList []ENIMetadata, err error) // DescribeENI returns the IPv4 addresses of eni interface and eni attachment id DescribeENI(eniID string) (addrList []*ec2.NetworkInterfacePrivateIpAddress, attachemdID *string, err error) // AllocIPAddress allocates an ip address for an eni AllocIPAddress(eniID string) error // AllocAllIPAddress allocates all ip addresses available on an eni AllocAllIPAddress(eniID string) error // GetVPCIPv4CIDR returns vpc's cidr GetVPCIPv4CIDR() string // GetLocalIPv4 returns the primary IP address on the primary eni interface GetLocalIPv4() string // GetPrimaryENI returns the primary eni GetPrimaryENI() string // GetENIipLimit returns the number IP address can be allocated on a ENI GetENIipLimit() (int64, error) // GetENILimit returns the number of enis can be attached to an instance GetENILimit() (int, error) }
APIs defines interfaces calls for adding/getting/deleting ENIs/secondary IPs. The APIs are not thread-safe.
type EC2InstanceMetadataCache ¶
type EC2InstanceMetadataCache struct {
// contains filtered or unexported fields
}
EC2InstanceMetadataCache caches instance metadata
func (*EC2InstanceMetadataCache) AllocAllIPAddress ¶
func (cache *EC2InstanceMetadataCache) AllocAllIPAddress(eniID string) error
AllocAllIPAddress allocates all IP addresses available on eni
func (*EC2InstanceMetadataCache) AllocENI ¶
func (cache *EC2InstanceMetadataCache) AllocENI() (string, error)
AllocENI creates an eni and attach it to the instance returns: newly created eni id
func (*EC2InstanceMetadataCache) AllocIPAddress ¶
func (cache *EC2InstanceMetadataCache) AllocIPAddress(eniID string) error
AllocIPAddress allocates an IP address for an ENI
func (*EC2InstanceMetadataCache) DescribeENI ¶
func (cache *EC2InstanceMetadataCache) DescribeENI(eniID string) ([]*ec2.NetworkInterfacePrivateIpAddress, *string, error)
DescribeENI returns the IPv4 addresses of interface and the attachment id return: private IP address, attachment id, error
func (*EC2InstanceMetadataCache) FreeENI ¶
func (cache *EC2InstanceMetadataCache) FreeENI(eniName string) error
FreeENI detachs ENI interface and delete ENI interface
func (*EC2InstanceMetadataCache) GetAttachedENIs ¶
func (cache *EC2InstanceMetadataCache) GetAttachedENIs() (eniList []ENIMetadata, err error)
GetAttachedENIs retrieves ENI information from meta data service
func (*EC2InstanceMetadataCache) GetENILimit ¶
func (cache *EC2InstanceMetadataCache) GetENILimit() (int, error)
GetENILimit returns the number of enis can be attached to an instance
func (*EC2InstanceMetadataCache) GetENIipLimit ¶
func (cache *EC2InstanceMetadataCache) GetENIipLimit() (int64, error)
GetENIipLimit return IP address limit per ENI based on EC2 instance type
func (*EC2InstanceMetadataCache) GetLocalIPv4 ¶
func (cache *EC2InstanceMetadataCache) GetLocalIPv4() string
GetLocalIPv4 returns the primary IP address on the primary interface
func (*EC2InstanceMetadataCache) GetPrimaryENI ¶
func (cache *EC2InstanceMetadataCache) GetPrimaryENI() string
GetPrimaryENI returns the primary ENI
func (*EC2InstanceMetadataCache) GetVPCIPv4CIDR ¶
func (cache *EC2InstanceMetadataCache) GetVPCIPv4CIDR() string
GetVPCIPv4CIDR returns VPC CIDR
type ENIMetadata ¶
type ENIMetadata struct { // ENIID is the id of network interface ENIID string // MAC is the mac address of network interface MAC string // DeviceNumber is the device number of network interface DeviceNumber int64 // 0 means it is primary interface // SubnetIPv4CIDR is the ipv4 cider of network interface SubnetIPv4CIDR string // The ip addresses allocated for the network interface LocalIPv4s []string }
ENIMetadata contains ENI information retrieved from EC2 meta data service