types

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2023 License: Apache-2.0 Imports: 15 Imported by: 13

Documentation

Index

Constants

View Source
const (
	TagKeyClusterID = "ack.aliyun.com"

	// NetworkInterfaceTagCreatorKey denotes the creator tag's key of network interface
	NetworkInterfaceTagCreatorKey = "creator"
	// NetworkInterfaceTagCreatorValue denotes the creator tag's value of network interface
	NetworkInterfaceTagCreatorValue = "terway"

	// TagTerwayController terway controller
	TagTerwayController = "terway-controller"

	TagENIAllocPolicy = "eni-alloc-policy"

	TagK8SNodeName = "node-name"

	TagKubernetesPodName      = "k8s_pod_name"
	TagKubernetesPodNamespace = "k8s_pod_namespace"
)

this keys is used in alibabacloud resource

View Source
const (
	// TrunkOn is the key for eni
	TrunkOn = AnnotationPrefix + "trunk-on"

	// PodENI whether pod is using podENI cr resource
	PodENI        = AnnotationPrefix + "pod-eni"
	PodNetworking = AnnotationPrefix + "pod-networking"

	// PodIPReservation whether pod's IP will be reserved for a reuse
	PodIPReservation = AnnotationPrefix + "pod-ip-reservation"

	// PodNetworks for additional net config
	PodNetworks = AnnotationPrefix + "pod-networks"

	// PodAllocType for additional net config
	PodAllocType = AnnotationPrefix + "pod-alloc-type"

	// PodENIAllocated pod annotation for allocated eni
	PodENIAllocated = AnnotationPrefix + "allocated"

	// PodUID store pod uid
	PodUID = AnnotationPrefix + "pod-uid"

	// NetworkPriority set pod network priority
	NetworkPriority = AnnotationPrefix + "network-priority"

	ENIAllocFromPool   = AnnotationPrefix + "eni-alloc-from-pool"
	ENIRelatedNodeName = AnnotationPrefix + "node"

	PodIPs = AnnotationPrefix + "pod-ips"

	// IgnoreByTerway if the label exist , terway will not handle this kind of res
	IgnoreByTerway = LabelPrefix + "ignore-by-terway"
)

annotations used by terway

View Source
const (
	EventCreateENISucceed = "CreateENISucceed"

	EventCreateENIFailed  = "CreateENIFailed"
	EventAttachENISucceed = "AttachENISucceed"
	EventAttachENIFailed  = "AttachENIFailed"
	EventDetachENISucceed = "DetachENISucceed"
	EventDetachENIFailed  = "DetachENIFailed"
	EventDeleteENISucceed = "DeleteENISucceed"
	EventDeleteENIFailed  = "DeleteENIFailed"

	EventUpdatePodENIFailed = "UpdatePodENIFailed"

	EventSyncPodNetworkingSucceed = "SyncPodNetworkingSucceed"
	EventSyncPodNetworkingFailed  = "SyncPodNetworkingFailed"
)

events for control plane

View Source
const (
	SufficientIPCondition   corev1.NodeConditionType = "SufficientIP"
	IPResInsufficientReason string                   = "InsufficientIP"
	IPResSufficientReason   string                   = "SufficientIP"
)

SufficientIPCondition definitions

View Source
const (
	PayByBandwidth = InternetChargeType("PayByBandwidth")
	PayByTraffic   = InternetChargeType("PayByTraffic")
)

EIP pay type

View Source
const (
	ResourceTypeVeth  = "veth"
	ResourceTypeENI   = "eni"
	ResourceTypeENIIP = "eniIp"
	ResourceTypeEIP   = "eip"
)

network resource type

View Source
const (
	VSwitchSelectionPolicyRandom  = "random"
	VSwitchSelectionPolicyOrdered = "ordered"
)

Vswitch Selection Policy

View Source
const (
	IPAMTypeCRD       = "crd"
	IPAMTypePreferCRD = "preferCRD"
	IPAMTypeDefault   = ""
)

how terway deal with ip resource

View Source
const (
	ENICapPolicyPreferTrunk = "preferTrunk"
	ENICapPolicyDefault     = ""
)

how eni cap is calculated

View Source
const AnnotationPrefix = "k8s.aliyun.com/"

AnnotationPrefix is the annotation prefix

View Source
const FinalizerPodENI = "pod-eni"

FinalizerPodENI finalizer for podENI resource

View Source
const LabelPrefix = "k8s.aliyun.com/"

Variables

View Source
var Scheme = runtime.NewScheme()

Functions

func IgnoredByTerway added in v1.5.5

func IgnoredByTerway(labels map[string]string) bool

IgnoredByTerway for both pods and nodes

func NewRESTMapper added in v1.6.0

func NewRESTMapper() meta.RESTMapper

func PodUseENI added in v1.1.0

func PodUseENI(pod *corev1.Pod) bool

PodUseENI whether pod is use podENI cr res

Types

type EIP added in v1.1.0

type EIP struct {
	ID             string
	Address        net.IP
	Delete         bool // delete related eip on pod deletion
	AssociateENI   string
	AssociateENIIP net.IP
}

EIP Aliyun public ip

func (*EIP) GetResourceID added in v1.1.0

func (e *EIP) GetResourceID() string

GetResourceID return eip id

func (*EIP) GetType added in v1.1.0

func (e *EIP) GetType() string

GetType return type name

func (*EIP) ToResItems added in v1.1.0

func (e *EIP) ToResItems() []ResourceItem

type ENI

type ENI struct {
	ID               string
	MAC              string
	SecurityGroupIDs []string

	Trunk bool

	PrimaryIP IPSet
	GatewayIP IPSet

	VSwitchCIDR IPNetSet

	VSwitchID string
}

ENI aliyun ENI resource

func (*ENI) GetResourceID added in v1.1.0

func (e *ENI) GetResourceID() string

GetResourceID return mac address of eni

func (*ENI) GetType added in v1.0.10

func (e *ENI) GetType() string

GetType return type name

func (*ENI) ToResItems added in v1.1.0

func (e *ENI) ToResItems() []ResourceItem

type ENICapPolicy added in v1.2.0

type ENICapPolicy string

ENICapPolicy how eni cap is calculated

type ENIIP added in v1.0.10

type ENIIP struct {
	ENI   *ENI
	IPSet IPSet
}

ENIIP aliyun secondary IP resource

func (*ENIIP) GetResourceID added in v1.1.0

func (e *ENIIP) GetResourceID() string

GetResourceID return mac address of eni and secondary ip address

func (*ENIIP) GetType added in v1.0.10

func (e *ENIIP) GetType() string

GetType return type name

func (*ENIIP) ToResItems added in v1.1.0

func (e *ENIIP) ToResItems() []ResourceItem

type ExtraEipInfo added in v1.1.0

type ExtraEipInfo struct {
	Delete         bool   `json:"delete"` // delete related eip on pod deletion
	AssociateENI   string `json:"associate_eni"`
	AssociateENIIP net.IP `json:"associate_eniip"`
}

ExtraEipInfo store extra eip info To judge whether delete user eip instance

type FakeRes added in v1.1.0

type FakeRes struct {
	ID     string
	Type   string
	Status ResStatus
}

FakeRes for test

func (*FakeRes) GetID added in v1.1.0

func (r *FakeRes) GetID() string

GetID GetID

func (*FakeRes) GetStatus added in v1.1.0

func (r *FakeRes) GetStatus() ResStatus

GetStatus GetStatus

func (*FakeRes) GetType added in v1.1.0

func (r *FakeRes) GetType() string

GetType GetType

type IPAMType added in v1.2.0

type IPAMType string

IPAMType how terway deal with ip resource

type IPFamily added in v1.1.0

type IPFamily struct {
	IPv4 bool
	IPv6 bool
}

func NewIPFamilyFromIPStack added in v1.1.0

func NewIPFamilyFromIPStack(ipStack IPStack) *IPFamily

NewIPFamilyFromIPStack parse IPStack to IPFamily

type IPInsufficientError added in v1.5.7

type IPInsufficientError struct {
	Err    error
	Reason string
}

func (*IPInsufficientError) Error added in v1.5.7

func (e *IPInsufficientError) Error() string

type IPNetSet added in v1.1.0

type IPNetSet struct {
	IPv4 *net.IPNet
	IPv6 *net.IPNet
}

func BuildIPNet added in v1.1.0

func BuildIPNet(ip, subnet *rpc.IPSet) (*IPNetSet, error)

func ToIPNetSet added in v1.1.0

func ToIPNetSet(ip *rpc.IPSet) (*IPNetSet, error)

func (*IPNetSet) SetIPNet added in v1.1.0

func (i *IPNetSet) SetIPNet(str string) *IPNetSet

func (*IPNetSet) String added in v1.1.0

func (i *IPNetSet) String() string

func (*IPNetSet) ToRPC added in v1.1.0

func (i *IPNetSet) ToRPC() *rpc.IPSet

type IPSet added in v1.1.0

type IPSet struct {
	IPv4 net.IP
	IPv6 net.IP
}

IPSet is the type hole both ipv4 and ipv6 net.IP

func MergeIPs added in v1.1.0

func MergeIPs(a, b []net.IP) []IPSet

func ToIPSet added in v1.1.0

func ToIPSet(ip *rpc.IPSet) (*IPSet, error)

func (*IPSet) GetIPv4 added in v1.1.0

func (i *IPSet) GetIPv4() string

func (*IPSet) GetIPv6 added in v1.1.0

func (i *IPSet) GetIPv6() string

func (*IPSet) SetIP added in v1.1.0

func (i *IPSet) SetIP(str string) *IPSet

func (*IPSet) String added in v1.1.0

func (i *IPSet) String() string

func (*IPSet) ToRPC added in v1.1.0

func (i *IPSet) ToRPC() *rpc.IPSet

type IPStack added in v1.1.0

type IPStack string

IPStack is the ip family type

const (
	IPStackIPv4 IPStack = "ipv4"
	IPStackDual IPStack = "dual"
	IPStackIPv6 IPStack = "ipv6"
)

IPStack is the ip family type

type InternetChargeType added in v1.1.0

type InternetChargeType string

type NetworkPrio added in v1.3.0

type NetworkPrio string

NetworkPrio network priority for pod

const (
	NetworkPrioBestEffort NetworkPrio = "best-effort"
	NetworkPrioBurstable  NetworkPrio = "burstable"
	NetworkPrioGuaranteed NetworkPrio = "guaranteed"
)

NetworkPrio val

type NetworkResource added in v1.0.10

type NetworkResource interface {
	GetResourceID() string
	GetType() string
	ToResItems() []ResourceItem
}

NetworkResource interface of network resources

type PodEipInfo added in v1.1.0

type PodEipInfo struct {
	PodEip                   bool
	PodEipID                 string
	PodEipIP                 string
	PodEipBandWidth          int
	PodEipChargeType         InternetChargeType
	PodEipISP                string
	PodEipPoolID             string
	PodEipBandwidthPackageID string
}

PodEipInfo store pod eip info NOTE: this is the type store in db

type PodIPTypeIPs added in v1.5.7

type PodIPTypeIPs string

PodIPTypeIPs Pod IP address type

const (
	NormalIPTypeIPs    PodIPTypeIPs = AnnotationPrefix + "max-available-ip"
	MemberENIIPTypeIPs PodIPTypeIPs = AnnotationPrefix + "max-member-eni-ip"
	ERDMAIPTypeIPs     PodIPTypeIPs = AnnotationPrefix + "max-erdma-ip"
)

PodIPTypeIPs val

type PodInfo added in v1.1.0

type PodInfo struct {
	//K8sPod *v1.Pod
	Name            string
	Namespace       string
	TcIngress       uint64
	TcEgress        uint64
	PodNetworkType  string
	PodIP           string // used for eip and mip
	PodIPs          IPSet  // used for eip and mip
	SandboxExited   bool
	EipInfo         PodEipInfo
	IPStickTime     time.Duration
	PodENI          bool
	PodUID          string
	NetworkPriority string
}

PodInfo store the pod info NOTE: this is the type store in db

type PodResources added in v1.1.0

type PodResources struct {
	Resources   []ResourceItem
	PodInfo     *PodInfo
	NetNs       *string
	ContainerID *string
}

PodResources pod resources related

func (PodResources) GetResourceItemByType added in v1.1.0

func (p PodResources) GetResourceItemByType(resType string) []ResourceItem

GetResourceItemByType get pod resource by resource type

type PoolConfig

type PoolConfig struct {
	Capacity     int // the max res can hold in the pool
	MaxENI       int // the max eni terway can be created (already exclude main eni)
	MaxMemberENI int // the max member eni can be created
	MaxIPPerENI  int

	MaxPoolSize int
	MinPoolSize int

	ZoneID           string
	VSwitchOptions   []string
	ENITags          map[string]string
	SecurityGroupIDs []string
	InstanceID       string

	VSwitchSelectionPolicy string

	DisableSecurityGroupCheck bool

	TrunkENIID string
}

PoolConfig configuration of pool and resource factory

type Res added in v1.1.0

type Res interface {
	GetID() string
	GetType() string
	GetStatus() ResStatus
}

Res is the func for res

type ResStatus added in v1.1.0

type ResStatus int

ResStatus ResStatus

const (
	ResStatusInvalid ResStatus = iota
	ResStatusIdle
	ResStatusInUse
)

ResStatus

type ResourceItem added in v1.1.0

type ResourceItem struct {
	Type         string        `json:"type"`
	ID           string        `json:"id"`
	ExtraEipInfo *ExtraEipInfo `json:"extra_eip_info"`

	ENIID  string `json:"eni_id"`
	ENIMAC string `json:"eni_mac"`
	IPv4   string `json:"ipv4"`
	IPv6   string `json:"ipv6"`
}

ResourceItem to be store

type Veth added in v1.0.10

type Veth struct {
	HostVeth string
}

Veth veth pair resource on system

func (*Veth) GetResourceID added in v1.1.0

func (e *Veth) GetResourceID() string

GetResourceID return host veth name of veth resource

func (*Veth) GetType added in v1.0.10

func (e *Veth) GetType() string

GetType return type name

func (*Veth) ToResItems added in v1.1.0

func (e *Veth) ToResItems() []ResourceItem

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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