ocicni

package
v0.0.0-...-8680cc4 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: Apache-2.0 Imports: 17 Imported by: 6

Documentation

Index

Constants

View Source
const (
	// CNIChangeEventPodCIDR is a subject type to update the podCIDR for the default pod network.
	CNIChangeEventPodCIDR = "pod-cidr-change"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CniManager

type CniManager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

CniManager is an implementation of interface CniMgr.

func (*CniManager) CloseNetNS

func (c *CniManager) CloseNetNS(path string) error

CloseNetNS cleans up this instance of the network namespace; if this instance is the last user the namespace will be destroyed

func (*CniManager) Event

func (c *CniManager) Event(subject string, detail interface{}) error

Event handle the changes of CNI. only support updatePodCIDR now.

func (*CniManager) GetDefaultNetworkName

func (c *CniManager) GetDefaultNetworkName() string

GetDefaultNetworkName returns the name of the plugin's default network.

func (*CniManager) GetPodNetworkStatus

func (c *CniManager) GetPodNetworkStatus(netnsPath string) (string, error)

GetPodNetworkStatus is the method called to obtain the ipv4 or ipv6 addresses of the pod sandbox.

func (*CniManager) Name

func (c *CniManager) Name() string

Name returns the plugin's name. This will be used when searching for a plugin by name, e.g.

func (*CniManager) NewNetNS

func (c *CniManager) NewNetNS() (string, error)

NewNetNS creates a new persistent network namespace and returns the namespace path, without switching to it

func (*CniManager) RecoverNetNS

func (c *CniManager) RecoverNetNS(path string) error

RecoverNetNS recreate a persistent network namespace if the ns is not exists. Otherwise, do nothing.

func (*CniManager) RemoveNetNS

func (c *CniManager) RemoveNetNS(path string) error

RemoveNetNS unmounts the network namespace

func (*CniManager) SetUpPodNetwork

func (c *CniManager) SetUpPodNetwork(podNetwork *ocicni.PodNetwork) error

SetUpPodNetwork is the method called after the sandbox container of the pod has been created but before the other containers of the pod are launched.

func (*CniManager) Status

func (c *CniManager) Status() error

Status returns error if the network plugin is in error state.

func (*CniManager) TearDownPodNetwork

func (c *CniManager) TearDownPodNetwork(podNetwork *ocicni.PodNetwork) error

TearDownPodNetwork is the method called before a pod's sandbox container will be deleted.

type CniMgr

type CniMgr interface {
	// Name returns the plugin's name. This will be used when searching
	// for a plugin by name, e.g.
	Name() string

	// GetDefaultNetworkName returns the name of the plugin's default
	// network.
	GetDefaultNetworkName() string

	// SetUpPodNetwork is the method called after the sandbox container of the
	// pod has been created but before the other containers of the pod
	// are launched.
	SetUpPodNetwork(podNetwork *ocicni.PodNetwork) error

	// TearDownPodNetwork is the method called before a pod's sandbox container will be deleted.
	TearDownPodNetwork(podNetwork *ocicni.PodNetwork) error

	// GetPodNetworkStatus is the method called to obtain the ipv4 or ipv6 addresses of the pod sandbox.
	GetPodNetworkStatus(netnsPath string) (string, error)

	// Status returns error if the network plugin is in error state.
	Status() error

	// Event handle the changes of CNI.
	Event(subject string, detail interface{}) error

	// NewNetNS creates a new persistent network namespace and returns the
	// namespace path, without switching to it
	NewNetNS() (string, error)

	// RemoveNetNS unmounts the network namespace
	RemoveNetNS(path string) error

	// CloseNetNS cleans up this instance of the network namespace; if this instance
	// is the last user the namespace will be destroyed
	CloseNetNS(path string) error

	// RecoverNetNS recreate a persistent network namespace if the ns is not exists.
	// Otherwise, do nothing.
	RecoverNetNS(path string) error
}

CniMgr as an interface defines all operations against CNI.

func NewCniManager

func NewCniManager(cfg *config.Config) (CniMgr, error)

NewCniManager initializes a brand new cni manager.

Jump to

Keyboard shortcuts

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