daemon

package
v1.17.7 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: Apache-2.0 Imports: 23 Imported by: ? modules, 0 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 (
	PodNetworkTypeVPCENI     = "VPCENI"
	PodNetworkTypeENIMultiIP = "ENIMultiIP"
)
View Source
const (
	ResourceTypeENI   = "eni"
	ResourceTypeENIIP = "eniIp"
)

network resource type

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

Vswitch Selection Policy

Variables

This section is empty.

Functions

func DisableFeature added in v1.13.7

func DisableFeature(features *Feat, feature Feat)

func EnableFeature added in v1.13.7

func EnableFeature(features *Feat, feature Feat)

func GetAddonSecret added in v1.8.0

func GetAddonSecret() (string, string, error)

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

func IsFeatureEnabled added in v1.13.7

func IsFeatureEnabled(features Feat, feature Feat) bool

func MergeENITagBlockList added in v1.17.7

func MergeENITagBlockList(userList []networkv1beta1.ENITagBlockListItem) []networkv1beta1.ENITagBlockListItem

MergeENITagBlockList combines the user-supplied list with the built-in DefaultENITagBlockList, dedup by (key, value). Always returns the defaults even when userList is empty, so the built-in block rules are always in effect.

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"`
	IPWarmUpSize   *int                `yaml:"ip_warm_up_size" json:"ip_warm_up_size"`

	IdleIPReclaimAfter        *string `yaml:"idle_ip_reclaim_after,omitempty" json:"idle_ip_reclaim_after,omitempty"`
	IdleIPReclaimBatchSize    int     `yaml:"idle_ip_reclaim_batch_size,omitempty" json:"idle_ip_reclaim_batch_size,omitempty"`
	IdleIPReclaimInterval     *string `yaml:"idle_ip_reclaim_interval,omitempty" json:"idle_ip_reclaim_interval,omitempty"`
	IdleIPReclaimJitterFactor *string `yaml:"idle_ip_reclaim_jitter_factor,omitempty" json:"idle_ip_reclaim_jitter_factor,omitempty"`

	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
	BackoffOverride             map[string]backoff.ExtendedBackoff `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
	// ENITagBlockList augments the built-in DefaultENITagBlockList. Any ENI
	// carrying a (key, value) pair listed here (or in the default list) is
	// ignored by terway: not added to the pool, not used for Pod IP
	// allocation. Use this to coexist with other ENI managers.
	ENITagBlockList   []networkv1beta1.ENITagBlockListItem `json:"eni_tag_block_list,omitempty"`
	KubeClientQPS     float32                              `json:"kube_client_qps"`
	KubeClientBurst   int                                  `json:"kube_client_burst"`
	ResourceGroupID   string                               `json:"resource_group_id"`
	RateLimit         map[string]int                       `json:"rate_limit"`
	EnablePatchPodIPs *bool                                `json:"enable_patch_pod_ips,omitempty"  mod:"default=true"`
	IPPoolSyncPeriod  string                               `json:"ip_pool_sync_period"`
	EnableIPPrefix    bool                                 `json:"enable_ip_prefix,omitempty"`
	// IPv4PrefixCount specifies the total number of IPv4 prefixes to allocate across all ENIs.
	// Effective in IPv4 single-stack and dual-stack modes.
	// In dual-stack mode, each ENI automatically gets exactly one IPv6 prefix alongside IPv4 prefixes.
	IPv4PrefixCount int `json:"ipv4_prefix_count,omitempty"`
	// IPv6PrefixCount specifies the total number of IPv6 prefixes to allocate.
	// Only effective in IPv6 single-stack mode. Valid values: 0 or 1.
	// Ignored in dual-stack mode (IPv6 prefixes are managed automatically, one per ENI).
	IPv6PrefixCount int `json:"ipv6_prefix_count,omitempty"`
}

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) GetIPPoolSYncPeriod added in v1.15.0

func (c *Config) GetIPPoolSYncPeriod() time.Duration

func (*Config) GetIPStack added in v1.15.0

func (c *Config) GetIPStack() (bool, bool)

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 ENIConfig added in v1.13.7

type ENIConfig struct {
	ZoneID           string
	VSwitchOptions   []string
	ENITags          map[string]string
	SecurityGroupIDs []string
	InstanceID       string

	VSwitchSelectionPolicy vswitch.SelectionPolicy
	EniSelectionPolicy     EniSelectionPolicy

	ResourceGroupID string

	EniTypeAttr Feat

	EnableIPv4 bool
	EnableIPv6 bool

	TagFilter map[string]string
}

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 EniSelectionPolicy added in v1.13.7

type EniSelectionPolicy string
const (
	EniSelectionPolicyLeastIPs EniSelectionPolicy = "least_ips"
	EniSelectionPolicyMostIPs  EniSelectionPolicy = "most_ips"
)

Network interface Selection Policy

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 Feat added in v1.13.7

type Feat uint8
const (
	FeatTrunk Feat = 1 << iota
	FeatERDMA
)

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 // deprecated
	PodENI          bool
	PodUID          string
	NetworkPriority string
	ERdma           bool
	CreateTime      time.Time // pod creation timestamp
}

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 PoolConfig added in v1.13.7

type PoolConfig struct {
	EnableIPv4 bool
	EnableIPv6 bool

	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
	ERdmaCapacity int // the max erdma res can be created
	MaxIPPerENI   int
	BatchSize     int

	MaxPoolSize int
	MinPoolSize int

	ReclaimBatchSize int
	ReclaimInterval  time.Duration
	ReclaimAfter     time.Duration
	ReclaimFactor    float64
}

PoolConfig configuration of pool and resource factory

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

Jump to

Keyboard shortcuts

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