daemon

package
v1.9.6 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PodNetworkTypeVPCIP      = "VPCIP"
	PodNetworkTypeVPCENI     = "VPCENI"
	PodNetworkTypeENIMultiIP = "ENIMultiIP"
)
View Source
const (
	ResourceTypeVeth  = "veth"
	ResourceTypeENI   = "eni"
	ResourceTypeENIIP = "eniIp"
	ResourceTypeEIP   = "eip"
)

network resource type

View Source
const (
	ModeVPC        = "VPC"
	ModeENIMultiIP = "ENIMultiIP"
	ModeENIOnly    = "ENIOnly"
)
View Source
const (
	VSwitchSelectionPolicyRandom  = "random"
	VSwitchSelectionPolicyOrdered = "ordered"
)

Vswitch Selection Policy

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

how eni cap is calculated

Variables

This section is empty.

Functions

func GetAddonSecret added in v1.8.0

func GetAddonSecret() (string, string, error)

GetAddonSecret return ak/sk from file, return nil if not present.

func SetConfig

func SetConfig(c *Config)

Types

type CNI added in v1.7.0

type CNI struct {
	PodName      string
	PodNamespace string
	PodID        string
	PodUID       string
	NetNSPath    string
}

type Config

type Config struct {
	Version                     string                  `yaml:"version" json:"version"`
	AccessID                    secret.Secret           `yaml:"access_key" json:"access_key"`
	AccessSecret                secret.Secret           `yaml:"access_secret" json:"access_secret"`
	RegionID                    string                  `yaml:"region_id" json:"region_id"`
	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" mod:"default=1"`
	EniCapShift                 int                     `yaml:"eni_cap_shift" json:"eni_cap_shift"`
	VSwitchSelectionPolicy      string                  `yaml:"vswitch_selection_policy" json:"vswitch_selection_policy" mod:"default=random"`
	EniSelectionPolicy          string                  `yaml:"eni_selection_policy" json:"eni_selection_policy" mod:"default=most_ips"`
	IPStack                     string                  `yaml:"ip_stack" json:"ip_stack" validate:"oneof=ipv4 ipv6 dual" mod:"default=ipv4"` // default ipv4 , support ipv4 dual
	EnableENITrunking           bool                    `yaml:"enable_eni_trunking" json:"enable_eni_trunking"`
	EnableERDMA                 bool                    `yaml:"enable_erdma" json:"enable_erdma"`
	CustomStatefulWorkloadKinds []string                `yaml:"custom_stateful_workload_kinds" json:"custom_stateful_workload_kinds"`
	IPAMType                    types.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"`
	DisableDevicePlugin         bool                    `json:"disable_device_plugin"`
	ENITagFilter                map[string]string       `json:"eni_tag_filter"` // if set , only enis match filter, will be managed
	KubeClientQPS               float32                 `json:"kube_client_qps"`
	KubeClientBurst             int                     `json:"kube_client_burst"`
	ResourceGroupID             string                  `json:"resource_group_id"`
}

Config configuration of terway daemon

func ConfigFromConfigMap

func ConfigFromConfigMap(ctx context.Context, client client.Client, nodeName string) (*Config, error)

ConfigFromConfigMap get eni-config form configmap if nodeName is not empty dynamic config is read

func GetConfig

func GetConfig() *Config

func GetConfigFromFileWithMerge

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

GetConfigFromFileWithMerge parse Config from file

func MergeConfigAndUnmarshal

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

func (*Config) GetExtraRoutes

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

func (*Config) GetSecurityGroups

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

func (*Config) GetVSwitchIDs

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

func (*Config) Populate added in v1.5.7

func (c *Config) Populate()

func (*Config) Validate added in v1.5.7

func (c *Config) Validate() error

type ENI added in v1.7.0

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

	Trunk bool
	ERdma bool

	PrimaryIP types.IPSet
	GatewayIP types.IPSet

	VSwitchCIDR types.IPNetSet

	VSwitchID string
}

ENI aliyun ENI resource

func (*ENI) GetResourceID added in v1.7.0

func (e *ENI) GetResourceID() string

GetResourceID return mac address of eni

func (*ENI) GetType added in v1.7.0

func (e *ENI) GetType() string

GetType return type name

func (*ENI) ToResItems added in v1.7.0

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

type ENICapPolicy added in v1.7.0

type ENICapPolicy string

ENICapPolicy how eni cap is calculated

type ENIIP added in v1.7.0

type ENIIP struct {
	ENI   *ENI
	IPSet types.IPSet
}

ENIIP aliyun secondary IP resource

func (*ENIIP) GetResourceID added in v1.7.0

func (e *ENIIP) GetResourceID() string

GetResourceID return mac address of eni and secondary ip address

func (*ENIIP) GetType added in v1.7.0

func (e *ENIIP) GetType() string

GetType return type name

func (*ENIIP) ToResItems added in v1.7.0

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

type ExtraEipInfo added in v1.7.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 InternetChargeType added in v1.7.0

type InternetChargeType string

DEPRECATED

type NetworkResource added in v1.7.0

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

NetworkResource interface of network resources

type PodEipInfo added in v1.7.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 DEPRECATED

type PodInfo added in v1.7.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          types.IPSet // used for eip and mip
	SandboxExited   bool
	EipInfo         PodEipInfo // deprecated
	IPStickTime     time.Duration
	PodENI          bool
	PodUID          string
	NetworkPriority string
	ERdma           bool
}

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

type PodResources added in v1.7.0

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

	NetConf string
}

PodResources pod resources related

func (PodResources) GetResourceItemByType added in v1.7.0

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

GetResourceItemByType get pod resource by resource type

type Res added in v1.7.0

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

Res is the func for res

type ResStatus added in v1.7.0

type ResStatus int

ResStatus ResStatus

const (
	ResStatusInvalid ResStatus = iota
	ResStatusIdle
	ResStatusInUse
)

ResStatus

type ResourceItem added in v1.7.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.7.0

type Veth struct {
	HostVeth string
}

Veth veth pair resource on system

func (*Veth) GetResourceID added in v1.7.0

func (e *Veth) GetResourceID() string

GetResourceID return host veth name of veth resource

func (*Veth) GetType added in v1.7.0

func (e *Veth) GetType() string

GetType return type name

func (*Veth) ToResItems added in v1.7.0

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

Jump to

Keyboard shortcuts

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