types

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2022 License: Apache-2.0 Imports: 15 Imported by: 6 modules, 13 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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"

	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"

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

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 (
	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

Variables

This section is empty.

Functions

func PodUseENI added in v1.1.0

func PodUseENI(pod *corev1.Pod) bool

PodUseENI whether pod is use podENI cr res

Types

type Configure

type Configure struct {
	Version                string              `yaml:"version" json:"version"`
	AccessID               string              `yaml:"access_key" json:"access_key"`
	AccessSecret           string              `yaml:"access_secret" json:"access_secret"`
	CredentialPath         string              `yaml:"credential_path" json:"credential_path"`
	ServiceCIDR            string              `yaml:"service_cidr" json:"service_cidr"`
	VSwitches              map[string][]string `yaml:"vswitches" json:"vswitches"`
	ENITags                map[string]string   `yaml:"eni_tags" json:"eni_tags"`
	MaxPoolSize            int                 `yaml:"max_pool_size" json:"max_pool_size"`
	MinPoolSize            int                 `yaml:"min_pool_size" json:"min_pool_size"`
	MinENI                 int                 `yaml:"min_eni" json:"min_eni"`
	MaxENI                 int                 `yaml:"max_eni" json:"max_eni"`
	Prefix                 string              `yaml:"prefix" json:"prefix"`
	SecurityGroup          string              `yaml:"security_group" json:"security_group"`
	SecurityGroups         []string            `yaml:"security_groups" json:"security_groups"`
	EniCapRatio            float64             `yaml:"eni_cap_ratio" json:"eni_cap_ratio"`
	EniCapShift            int                 `yaml:"eni_cap_shift" json:"eni_cap_shift"`
	VSwitchSelectionPolicy string              `yaml:"vswitch_selection_policy" json:"vswitch_selection_policy"`
	EnableEIPPool          string              `yaml:"enable_eip_pool" json:"enable_eip_pool"`
	IPStack                string              `yaml:"ip_stack" json:"ip_stack"` // default ipv4 , support ipv4 dual
	// rob the eip instance even the eip already bound to other resource
	AllowEIPRob                 string                  `yaml:"allow_eip_rob" json:"allow_eip_rob"`
	EnableENITrunking           bool                    `yaml:"enable_eni_trunking" json:"enable_eni_trunking"`
	CustomStatefulWorkloadKinds []string                `yaml:"custom_stateful_workload_kinds" json:"custom_stateful_workload_kinds"`
	IPAMType                    IPAMType                `yaml:"ipam_type" json:"ipam_type"`           // crd or default
	ENICapPolicy                ENICapPolicy            `yaml:"eni_cap_policy" json:"eni_cap_policy"` // prefer trunk or secondary
	BackoffOverride             map[string]wait.Backoff `json:"backoff_override,omitempty"`
	ExtraRoutes                 []route.Route           `json:"extra_routes,omitempty"`
}

Configure configuration of terway daemon

func GetConfigFromFileWithMerge added in v1.1.0

func GetConfigFromFileWithMerge(filePath string, cfg []byte) (*Configure, error)

GetConfigFromFileWithMerge parse Configure from file

func MergeConfigAndUnmarshal added in v1.1.0

func MergeConfigAndUnmarshal(topCfg, baseCfg []byte) (*Configure, error)

func (*Configure) GetExtraRoutes added in v1.2.1

func (c *Configure) GetExtraRoutes() []string

func (*Configure) GetSecurityGroups added in v1.2.0

func (c *Configure) GetSecurityGroups() []string

func (*Configure) GetVSwitchIDs added in v1.2.1

func (c *Configure) GetVSwitchIDs() []string

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 EIPInstanceType added in v1.1.0

type EIPInstanceType string
const EIPInstanceTypeNetworkInterface EIPInstanceType = "NetworkInterface"

type ENI

type ENI struct {
	ID               string
	MAC              string
	MaxIPs           int
	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 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 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
}

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

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
}

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
}

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 {
	MaxPoolSize            int
	MinPoolSize            int
	MinENI                 int
	MaxENI                 int
	VPC                    string
	Zone                   string
	VSwitch                []string
	ENITags                map[string]string
	SecurityGroups         []string
	InstanceID             string
	AccessID               string
	AccessSecret           string
	EniCapRatio            float64
	EniCapShift            int
	VSwitchSelectionPolicy string
	EnableENITrunking      bool
	ENICapPolicy           ENICapPolicy
}

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