Documentation ¶
Index ¶
- Constants
- Variables
- func NewAliyunImpl(openAPI *OpenAPI, needENITypeAttr bool, ipFamily *types.IPFamily) ipam.API
- func UpdateFromAPI(client *ecs.Client, instanceType string) error
- type ClientMgr
- type ENIInfoGetter
- type ENIMetadata
- func (e *ENIMetadata) GetENIByMac(mac string) (*types.ENI, error)
- func (e *ENIMetadata) GetENIPrivateAddressesByMAC(mac string) ([]net.IP, error)
- func (e *ENIMetadata) GetENIPrivateIPv6AddressesByMAC(mac string) ([]net.IP, error)
- func (e *ENIMetadata) GetENIs(containsMainENI bool) ([]*types.ENI, error)
- func (e *ENIMetadata) GetSecondaryENIMACs() ([]string, error)
- type ENIStatus
- type ENIType
- type Impl
- func (e *Impl) AllocateENI(ctx context.Context, vSwitch, securityGroup, instanceID string, trunk bool, ...) (*types.ENI, error)
- func (e *Impl) AllocateEipAddress(ctx context.Context, bandwidth int, chargeType types.InternetChargeType, ...) (*types.EIP, error)
- func (e *Impl) AssignNIPsForENI(ctx context.Context, eniID, mac string, count int) (ipSet []types.IPSet, err error)
- func (e *Impl) CheckEniSecurityGroup(ctx context.Context, sg []string) error
- func (e *Impl) FreeENI(ctx context.Context, eniID, instanceID string) error
- func (e *Impl) GetAttachedENIs(ctx context.Context, containsMainENI bool) ([]*types.ENI, error)
- func (e *Impl) GetAttachedSecurityGroups(ctx context.Context, instanceID string) ([]string, error)
- func (e *Impl) GetENIByMac(ctx context.Context, mac string) (*types.ENI, error)
- func (e *Impl) GetENIIPs(ctx context.Context, mac string) ([]net.IP, []net.IP, error)
- func (e *Impl) GetInstanceAttributesType(ctx context.Context, instanceID string) (*ecs.Instance, error)
- func (e *Impl) GetSecondaryENIMACs(ctx context.Context) ([]string, error)
- func (e *Impl) QueryEniIDByIP(ctx context.Context, vpcID string, address net.IP) (string, error)
- func (e *Impl) ReleaseEipAddress(ctx context.Context, eipID, eniID string, eniIP net.IP) error
- func (e *Impl) UnAssignIPsForENI(ctx context.Context, eniID, mac string, ipv4s []net.IP, ipv6s []net.IP) error
- func (e *Impl) UnassociateEipAddress(ctx context.Context, eipID, eniID, eniIP string) error
- func (e *Impl) WaitForEIP(eipID string, status string, backoff wait.Backoff) (*vpc.EipAddress, error)
- type Instance
- type Limits
- type OpenAPI
- func (a *OpenAPI) AssignIpv6Addresses(ctx context.Context, eniID string, count int) ([]net.IP, error)
- func (a *OpenAPI) AssignPrivateIPAddress(ctx context.Context, eniID string, count int) ([]net.IP, error)
- func (a *OpenAPI) AttachNetworkInterface(ctx context.Context, eniID, instanceID, trunkENIID string) error
- func (a *OpenAPI) CreateNetworkInterface(ctx context.Context, instanceType ENIType, vSwitch string, ...) (*ecs.CreateNetworkInterfaceResponse, error)
- func (a *OpenAPI) DeleteNetworkInterface(ctx context.Context, eniID string) error
- func (a *OpenAPI) DescribeNetworkInterface(ctx context.Context, vpcID string, eniID []string, instanceID string, ...) ([]ecs.NetworkInterfaceSet, error)
- func (a *OpenAPI) DescribeVSwitchByID(ctx context.Context, vSwitch string) (*vpc.VSwitch, error)
- func (a *OpenAPI) DetachNetworkInterface(ctx context.Context, eniID, instanceID, trunkENIID string) error
- func (a *OpenAPI) UnAssignIpv6Addresses(ctx context.Context, eniID string, ips []net.IP) error
- func (a *OpenAPI) UnAssignPrivateIPAddresses(ctx context.Context, eniID string, ips []net.IP) error
- func (a *OpenAPI) WaitForNetworkInterface(ctx context.Context, eniID string, status ENIStatus, backoff wait.Backoff, ...) (*ecs.NetworkInterfaceSet, error)
Constants ¶
const ( LogFieldAPI = "api" LogFieldRequestID = "requestID" LogFieldInstanceID = "instanceID" LogFieldSecondaryIPCount = "secondaryIPCount" LogFieldENIID = "eni" LogFieldEIPID = "eip" LogFieldPrivateIP = "privateIP" LogFieldVSwitchID = "vSwitchID" )
log fields
Variables ¶
var ( // ENIOpBackoff about 300s backoff ENIOpBackoff = wait.Backoff{ Duration: time.Second * 5, Factor: 2, Jitter: 0.3, Steps: 6, } // MetadataAssignPrivateIPBackoff about 10s backoff MetadataAssignPrivateIPBackoff = wait.Backoff{ Duration: time.Millisecond * 1100, Factor: 1, Jitter: 0.2, Steps: 10, } // MetadataUnAssignPrivateIPBackoff about 10s backoff MetadataUnAssignPrivateIPBackoff = wait.Backoff{ Duration: time.Millisecond * 1100, Factor: 1, Jitter: 0.2, Steps: 10, } )
Functions ¶
func NewAliyunImpl ¶ added in v1.1.0
NewAliyunImpl return new API implement object
func UpdateFromAPI ¶ added in v1.1.0
UpdateFromAPI updates limits for instance https://www.alibabacloud.com/help/doc-detail/25620.htm
Types ¶
type ClientMgr ¶
type ClientMgr struct { // protect things below sync.RWMutex // contains filtered or unexported fields }
ClientMgr manager of aliyun openapi clientset
func NewClientMgr ¶
func NewClientMgr(key, secret, credentialPath, regionID, secretNamespace, secretName string) (*ClientMgr, error)
NewClientMgr return new aliyun client manager
type ENIInfoGetter ¶
type ENIInfoGetter interface { GetENIByMac(mac string) (*types.ENI, error) GetENIPrivateAddressesByMAC(mac string) ([]net.IP, error) GetENIPrivateIPv6AddressesByMAC(mac string) ([]net.IP, error) GetENIs(containsMainENI bool) ([]*types.ENI, error) GetSecondaryENIMACs() ([]string, error) }
ENIInfoGetter interface to get eni information
type ENIMetadata ¶
type ENIMetadata struct {
// contains filtered or unexported fields
}
func NewENIMetadata ¶ added in v1.1.0
func NewENIMetadata(ipFamily *types.IPFamily) *ENIMetadata
func (*ENIMetadata) GetENIByMac ¶ added in v1.1.0
func (e *ENIMetadata) GetENIByMac(mac string) (*types.ENI, error)
func (*ENIMetadata) GetENIPrivateAddressesByMAC ¶ added in v1.1.0
func (e *ENIMetadata) GetENIPrivateAddressesByMAC(mac string) ([]net.IP, error)
func (*ENIMetadata) GetENIPrivateIPv6AddressesByMAC ¶ added in v1.1.0
func (e *ENIMetadata) GetENIPrivateIPv6AddressesByMAC(mac string) ([]net.IP, error)
func (*ENIMetadata) GetENIs ¶ added in v1.1.0
func (e *ENIMetadata) GetENIs(containsMainENI bool) ([]*types.ENI, error)
func (*ENIMetadata) GetSecondaryENIMACs ¶ added in v1.1.0
func (e *ENIMetadata) GetSecondaryENIMACs() ([]string, error)
GetSecondaryENIMACs return secondary ENI macs
type Impl ¶ added in v1.1.0
type Impl struct { *OpenAPI // contains filtered or unexported fields }
func (*Impl) AllocateENI ¶ added in v1.1.0
func (e *Impl) AllocateENI(ctx context.Context, vSwitch, securityGroup, instanceID string, trunk bool, ipCount int, eniTags map[string]string) (*types.ENI, error)
AllocateENI for instance
func (*Impl) AllocateEipAddress ¶ added in v1.1.0
func (*Impl) AssignNIPsForENI ¶ added in v1.1.0
func (*Impl) CheckEniSecurityGroup ¶ added in v1.1.0
CheckEniSecurityGroup will sync eni's security with ecs's security group
func (*Impl) GetAttachedENIs ¶ added in v1.1.0
GetAttachedENIs of instanceId containsMainENI is contains the main interface(eth0) of instance
func (*Impl) GetAttachedSecurityGroups ¶ added in v1.1.0
func (*Impl) GetENIByMac ¶ added in v1.1.0
func (*Impl) GetInstanceAttributesType ¶ added in v1.1.0
func (*Impl) GetSecondaryENIMACs ¶ added in v1.1.0
func (*Impl) QueryEniIDByIP ¶ added in v1.1.0
func (*Impl) ReleaseEipAddress ¶ added in v1.1.0
func (*Impl) UnAssignIPsForENI ¶ added in v1.1.0
func (*Impl) UnassociateEipAddress ¶ added in v1.1.0
UnassociateEipAddress un associate eip 1. if eni is deleted eip auto unassociated 2. if eip is deleted , return code is InvalidAllocationId.NotFound 3. if eip is not bind ,return code is IncorrectEipStatus
func (*Impl) WaitForEIP ¶ added in v1.1.0
func (e *Impl) WaitForEIP(eipID string, status string, backoff wait.Backoff) (*vpc.EipAddress, error)
WaitForEIP wait status of eni, ignore status if is empty
type Instance ¶ added in v1.1.0
type Instance struct { RegionID string ZoneID string VPCID string VSwitchID string PrimaryMAC string InstanceID string InstanceType string }
func GetInstanceMeta ¶ added in v1.1.0
func GetInstanceMeta() *Instance
type Limits ¶ added in v1.1.0
type Limits struct { // Adapters specifies the maximum number of interfaces that can be // attached to the instance Adapters int // IPv4PerAdapter is the maximum number of ipv4 addresses per adapter/interface IPv4PerAdapter int // IPv6PerAdapter is the maximum number of ipv6 addresses per adapter/interface IPv6PerAdapter int // MemberAdapterLimit is the number interfaces that type is member MemberAdapterLimit int }
Limits specifies the IPAM relevant instance limits
func (*Limits) ENIOnlyPod ¶ added in v1.1.0
func (*Limits) SupportIPv6 ¶ added in v1.1.0
type OpenAPI ¶ added in v1.1.0
type OpenAPI struct { ClientSet *ClientMgr ReadOnlyRateLimiter flowcontrol.RateLimiter MutatingRateLimiter flowcontrol.RateLimiter }
func (*OpenAPI) AssignIpv6Addresses ¶ added in v1.1.0
func (a *OpenAPI) AssignIpv6Addresses(ctx context.Context, eniID string, count int) ([]net.IP, error)
AssignIpv6Addresses assign ipv6 address
func (*OpenAPI) AssignPrivateIPAddress ¶ added in v1.1.0
func (a *OpenAPI) AssignPrivateIPAddress(ctx context.Context, eniID string, count int) ([]net.IP, error)
AssignPrivateIPAddress assign secondary ip
func (*OpenAPI) AttachNetworkInterface ¶ added in v1.1.0
func (a *OpenAPI) AttachNetworkInterface(ctx context.Context, eniID, instanceID, trunkENIID string) error
AttachNetworkInterface attach eni
func (*OpenAPI) CreateNetworkInterface ¶ added in v1.1.0
func (a *OpenAPI) CreateNetworkInterface(ctx context.Context, instanceType ENIType, vSwitch string, securityGroups []string, ipCount, ipv6Count int, eniTags map[string]string) (*ecs.CreateNetworkInterfaceResponse, error)
CreateNetworkInterface instanceType Secondary Trunk
func (*OpenAPI) DeleteNetworkInterface ¶ added in v1.1.0
DeleteNetworkInterface del eni by id
func (*OpenAPI) DescribeNetworkInterface ¶ added in v1.1.0
func (a *OpenAPI) DescribeNetworkInterface(ctx context.Context, vpcID string, eniID []string, instanceID string, instanceType ENIType, status ENIStatus) ([]ecs.NetworkInterfaceSet, error)
DescribeNetworkInterface list eni
func (*OpenAPI) DescribeVSwitchByID ¶ added in v1.1.0
DescribeVSwitchByID get vsw by id
func (*OpenAPI) DetachNetworkInterface ¶ added in v1.1.0
func (a *OpenAPI) DetachNetworkInterface(ctx context.Context, eniID, instanceID, trunkENIID string) error
DetachNetworkInterface detach eni
func (*OpenAPI) UnAssignIpv6Addresses ¶ added in v1.1.0
UnAssignIpv6Addresses remove ip from eni return ok if 1. eni is released 2. ip is already released 3. release success
func (*OpenAPI) UnAssignPrivateIPAddresses ¶ added in v1.1.0
UnAssignPrivateIPAddresses remove ip from eni return ok if 1. eni is released 2. ip is already released 3. release success