cninetwork

package
v0.0.0-...-a1b4a84 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Modifed from https://github.com/openfaas/faasd/blob/master/pkg/cninetwork/cni_network.go

Index

Constants

This section is empty.

Variables

View Source
var ErrLinkNotFound = errors.New("link not found")

Functions

func CNIGateway

func CNIGateway() (string, error)

func CreateCNINetwork

func CreateCNINetwork(ctx context.Context, fn *pb.Function) (*gocni.Result, error)

func DeleteCNINetwork

func DeleteCNINetwork(ctx context.Context, fn *pb.Function) error

func GetIPAddress

func GetIPAddress(fn *pb.Function) (string, error)

func GetIPAddressRaw

func GetIPAddressRaw(container string, PID int64) (string, error)

func Init

func Init(config *types.NetworkOption) error

InitNetwork initialize the default cni manager

func NSPathByPid

func NSPathByPid(pid int) string

func NSPathByPidWithRoot

func NSPathByPidWithRoot(root string, pid int) string

func Uninstall

func Uninstall() error

func WithNetNS

func WithNetNS(ns netns.NsHandle, work func() error) (err error)

func WithNetNSByPath

func WithNetNSByPath(path string, work func() error) error
func WithNetNSLink(ns netns.NsHandle, ifName string, work func(link netlink.Link) error) error

Types

type CNIManager

type CNIManager struct {
	// contains filtered or unexported fields
}
var (
	DefaultManager *CNIManager
)

func (*CNIManager) CNIGateway

func (m *CNIManager) CNIGateway() (string, error)

CNIGateway returns the gateway for default subnet

func (*CNIManager) CreateCNINetwork

func (m *CNIManager) CreateCNINetwork(ctx context.Context, fn *pb.Function) (*gocni.Result, error)

CreateCNINetwork creates a CNI network interface and attaches it to the context

func (*CNIManager) DeleteCNINetwork

func (m *CNIManager) DeleteCNINetwork(ctx context.Context, fn *pb.Function) error

DeleteCNINetwork deletes a CNI network based on container's id and pid

func (*CNIManager) GenerateJSON

func (m *CNIManager) GenerateJSON() []byte

func (*CNIManager) GetIPAddress

func (m *CNIManager) GetIPAddress(fn *pb.Function) (string, error)

GetIPAddress returns the IP address from container based on container name and PID

func (*CNIManager) GetIPAddressRaw

func (m *CNIManager) GetIPAddressRaw(container string, PID int64) (string, error)

func (*CNIManager) Init

func (m *CNIManager) Init(config *types.NetworkOption) error

InitNetwork initialize the default cni network for all function containers

func (*CNIManager) NetID

func (m *CNIManager) NetID(id string, pid int64) string

NetID generates the network IF based on task name and task PID

func (*CNIManager) NetNamespace

func (m *CNIManager) NetNamespace(fn *pb.Function) string

NetNamespace generates the namespace path based on task PID.

func (*CNIManager) Uninstall

func (m *CNIManager) Uninstall() error

Uninstall 删除所有网络 TODO: 完成后续工作

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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