Documentation
¶
Index ¶
- Constants
- Variables
- func IsCNINotInitialized(err error) bool
- func IsInvalidConfig(err error) bool
- func IsInvalidResult(err error) bool
- func IsNotFound(err error) bool
- func IsReadFailure(err error) bool
- func WithAllConf(c *libcni) error
- func WithDefaultConf(c *libcni) error
- func WithLoNetwork(c *libcni) error
- type BandWidth
- type CNI
- type CNIOpt
- func WithConf(bytes []byte) CNIOpt
- func WithConfFile(fileName string) CNIOpt
- func WithConfIndex(bytes []byte, index int) CNIOpt
- func WithConfListBytes(bytes []byte) CNIOpt
- func WithConfListFile(fileName string) CNIOpt
- func WithInterfacePrefix(prefix string) CNIOpt
- func WithMinNetworkCount(count int) CNIOpt
- func WithPluginConfDir(dir string) CNIOpt
- func WithPluginDir(dirs []string) CNIOpt
- func WithPluginMaxConfNum(max int) CNIOpt
- type CNIResult
- type ConfNetwork
- type Config
- type ConfigResult
- type DNS
- type IPConfig
- type IPRanges
- type Namespace
- type NamespaceOpts
- func WithArgs(k, v string) NamespaceOpts
- func WithCapability(name string, capability interface{}) NamespaceOpts
- func WithCapabilityBandWidth(bandWidth BandWidth) NamespaceOpts
- func WithCapabilityDNS(dns DNS) NamespaceOpts
- func WithCapabilityIPRanges(ipRanges []IPRanges) NamespaceOpts
- func WithCapabilityPortMap(portMapping []PortMapping) NamespaceOpts
- func WithLabels(labels map[string]string) NamespaceOpts
- type Network
- type NetworkConf
- type NetworkConfList
- type PortMapping
Constants ¶
const ( CNIPluginName = "cni" DefaultNetDir = "/etc/cni/net.d" DefaultCNIDir = "/opt/cni/bin" DefaultMaxConfNum = 1 VendorCNIDirTemplate = "%s/opt/%s/bin" DefaultPrefix = "eth" )
Variables ¶
var ( ErrCNINotInitialized = errors.New("cni plugin not initialized") ErrInvalidConfig = errors.New("invalid cni config") ErrNotFound = errors.New("not found") ErrRead = errors.New("failed to read config file") ErrInvalidResult = errors.New("invalid result") ErrLoad = errors.New("failed to load cni config") )
Functions ¶
func IsCNINotInitialized ¶
IsCNINotInitialized returns true if the error is due to cni config not being initialized
func IsInvalidConfig ¶
IsInvalidConfig returns true if the error is invalid cni config
func IsInvalidResult ¶
IsInvalidResult return true if the error is due to invalid cni result
func IsNotFound ¶
IsNotFound returns true if the error is due to a missing config or result
func IsReadFailure ¶
IsReadFailure return true if the error is a config read failure
func WithAllConf ¶
func WithAllConf(c *libcni) error
WithAllConf can be used to detect all network config files from the configured cni config directory and load them.
func WithDefaultConf ¶
func WithDefaultConf(c *libcni) error
WithDefaultConf can be used to detect the default network config file from the configured cni config directory and load it. Since the CNI spec does not specify a way to detect default networks, the convention chosen is - the first network configuration in the sorted list of network conf files as the default network.
func WithLoNetwork ¶
func WithLoNetwork(c *libcni) error
WithLoNetwork can be used to load the loopback network config.
Types ¶
type BandWidth ¶
type BandWidth struct {
IngressRate uint64
IngressBurst uint64
EgressRate uint64
EgressBurst uint64
}
BandWidth defines the ingress/egress rate and burst limits
type CNI ¶
type CNI interface {
// Setup setup the network for the namespace
Setup(ctx context.Context, id string, path string, opts ...NamespaceOpts) (*CNIResult, error)
// Remove tears down the network of the namespace.
Remove(ctx context.Context, id string, path string, opts ...NamespaceOpts) error
// Load loads the cni network config
Load(opts ...CNIOpt) error
// Status checks the status of the cni initialization
Status() error
// GetConfig returns a copy of the CNI plugin configurations as parsed by CNI
GetConfig() *ConfigResult
}
type CNIOpt ¶
type CNIOpt func(c *libcni) error
func WithConfFile ¶
WithConfFile can be used to load network config from an .conf file. Supported with absolute fileName with path only.
func WithConfIndex ¶
WithConfIndex can be used to load config directly from byte and set the interface name's index.
func WithConfListBytes ¶
WithConfListBytes can be used to load network config list directly from byte
func WithConfListFile ¶
WithConfListFile can be used to load network config from an .conflist file. Supported with absolute fileName with path only.
func WithInterfacePrefix ¶
WithInterfacePrefix sets the prefix for network interfaces e.g. eth or wlan
func WithMinNetworkCount ¶
WithMinNetworkCount can be used to configure the minimum networks to be configured and initialized for the status to report success. By default its 1.
func WithPluginConfDir ¶
WithPluginConfDir can be used to configure the cni configuration directory.
func WithPluginDir ¶
WithPluginDir can be used to set the locations of the cni plugin binaries
func WithPluginMaxConfNum ¶
WithPluginMaxConfNum can be used to configure the max cni plugin config file num.
type ConfNetwork ¶
type ConfNetwork struct {
Config *NetworkConfList
IFName string
}
type ConfigResult ¶
type ConfigResult struct {
PluginDirs []string
PluginConfDir string
PluginMaxConfNum int
Prefix string
Networks []*ConfNetwork
}
type DNS ¶
type DNS struct {
// List of DNS servers of the cluster.
Servers []string
// List of DNS search domains of the cluster.
Searches []string
// List of DNS options.
Options []string
}
DNS defines the dns config
type NamespaceOpts ¶
func WithArgs ¶
func WithArgs(k, v string) NamespaceOpts
func WithCapability ¶
func WithCapability(name string, capability interface{}) NamespaceOpts
func WithCapabilityBandWidth ¶
func WithCapabilityBandWidth(bandWidth BandWidth) NamespaceOpts
WithCapabilityBandWitdh adds support for traffic shaping: https://github.com/heptio/cni-plugins/tree/master/plugins/meta/bandwidth
func WithCapabilityDNS ¶
func WithCapabilityDNS(dns DNS) NamespaceOpts
WithCapabilityDNS adds support for dns
func WithCapabilityIPRanges ¶
func WithCapabilityIPRanges(ipRanges []IPRanges) NamespaceOpts
func WithCapabilityPortMap ¶
func WithCapabilityPortMap(portMapping []PortMapping) NamespaceOpts
Capabilities
type Network ¶
type Network struct {
// contains filtered or unexported fields
}
type NetworkConf ¶
NetworkConf is a source bytes to string conversion of cnilibrary.NetworkConfig
type NetworkConfList ¶
type NetworkConfList struct {
Name string
CNIVersion string
Plugins []*NetworkConf
Source string
}
NetworkConfList is a source bytes to string version of cnilibrary.NetworkConfigList