Documentation ¶
Index ¶
- func CreateNetNS(name string) error
- func DestroyNetNS(name string) error
- func GetPodIP(result *cnicurrent.Result) string
- func NewClient(pluginsDir, configsDir string) (*client, error)
- func PodNetNSPath(name string) string
- func ReadConfiguration(configDir string) (*libcni.NetworkConfigList, error)
- type Client
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateNetNS ¶
CreateNetNS creates new network namespace using provided name.
func DestroyNetNS ¶
DestroyNetNS deletes the network namespace pointed by provided name.
func GetPodIP ¶ added in v0.8.0
func GetPodIP(result *cnicurrent.Result) string
GetPodIP retrieves the IP address of the pod as a string. It uses the first IPv4 address if finds. If it fails to determine the pod IP or the result argument is nil, it returns an empty string.
func NewClient ¶
NewClient returns a client perpared to call plugins in `pluginsDir` using configurations found in `configsDir`.
func PodNetNSPath ¶
PodNetNSPath converts netns name to its path in host filesystem.
func ReadConfiguration ¶
func ReadConfiguration(configDir string) (*libcni.NetworkConfigList, error)
ReadConfiguration iterates over CNI config files in a directory and returns first configuration with non empty Plugins list.
Types ¶
type Client ¶
type Client interface { // AddSandboxToNetwork adds a pod sandbox to the CNI network. AddSandboxToNetwork(podID, podName, podNs string) (*cnicurrent.Result, error) // RemoveSandboxFromNetwork removes a pod sandbox from the CNI network. RemoveSandboxFromNetwork(podID, podName, podNs string) error // GetDummyNetwork creates a dummy network using CNI plugin. // It's used for making a dummy gateway for Calico CNI plugin. // It returns a CNI result and a path to the network namespace. GetDummyNetwork() (*cnicurrent.Result, string, error) }
Client provides an interface to CNI plugins.