ocicni

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultInterfaceName is the string to be used for the interface name inside the net namespace
	DefaultInterfaceName = "eth0"
	// CNIPluginName is the default name of the plugin
	CNIPluginName = "cni"
)
View Source
const (
	// DefaultConfDir is the default place to look for CNI Network
	DefaultConfDir = "/etc/cni/net.d"
	// DefaultBinDir is the default place to look for CNI config files
	DefaultBinDir = "/opt/cni/bin"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CNIPlugin

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

	// SetUpPod is the method called after the sandbox container of
	// the pod has been created but before the other containers of the
	// pod are launched.
	SetUpPod(network PodNetwork) ([]types.Result, error)

	// TearDownPod is the method called before a pod's sandbox container will be deleted
	TearDownPod(network PodNetwork) error

	// Status is the method called to obtain the ipv4 or ipv6 addresses of the pod sandbox
	GetPodNetworkStatus(network PodNetwork) ([]types.Result, error)

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

	// Shutdown terminates all driver operations
	Shutdown() error
}

CNIPlugin is the interface that needs to be implemented by a plugin

func InitCNI

func InitCNI(defaultNetName string, confDir string, binDirs ...string) (CNIPlugin, error)

InitCNI takes a binary directory in which to search for CNI plugins, and a configuration directory in which to search for CNI JSON config files. If no valid CNI configs exist, network requests will fail until valid CNI config files are present in the config directory. If defaultNetName is not empty, a CNI config with that network name will be used as the default CNI network, and container network operations will fail until that network config is present and valid.

type PodNetwork

type PodNetwork struct {
	// Name is the name of the sandbox.
	Name string
	// Namespace is the namespace of the sandbox.
	Namespace string
	// ID is the id of the sandbox container.
	ID string
	// NetNS is the network namespace path of the sandbox.
	NetNS string
	// PortMappings is the port mapping of the sandbox.
	PortMappings []PortMapping

	// Networks is a list of CNI network names to attach to the sandbox
	// Leave this list empty to attach the default network to the sandbox
	Networks []string
}

PodNetwork configures the network of a pod sandbox.

type PortMapping

type PortMapping struct {
	// HostPort is the port number on the host.
	HostPort int32 `json:"hostPort"`
	// ContainerPort is the port number inside the sandbox.
	ContainerPort int32 `json:"containerPort"`
	// Protocol is the protocol of the port mapping.
	Protocol string `json:"protocol"`
	// HostIP is the host ip to use.
	HostIP string `json:"hostIP"`
}

PortMapping maps to the standard CNI portmapping Capability see: https://github.com/containernetworking/cni/blob/master/CONVENTIONS.md

Jump to

Keyboard shortcuts

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