cni

package
v2.0.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2018 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Romana CNI plugin configures kubernetes pods on Romana network.

Index

Constants

View Source
const (
	DefaultCNILogFile     = "/var/log/romana/cni.log"
	AlternativeCNILogFile = "/var/tmp/romana-cni.log"
)
View Source
const DefaultSegmentID = "default"

Variables

This section is empty.

Functions

func AddEndpointRoute

func AddEndpointRoute(ifaceName string, ip *net.IPNet, nl nlRouteHandle) error

AddEndpointRoute adds return /32 route from host to pod. This function is designed to take nil as nlRouteHandle argument.

func CmdAdd

func CmdAdd(args *skel.CmdArgs) error

cmdAdd is a callback functions that gets called by skel.PluginMain in response to ADD method.

func CmdDel

func CmdDel(args *skel.CmdArgs) error

cmdDel is a callback functions that gets called by skel.PluginMain in response to DEL method.

func MakeDivertRules

func MakeDivertRules(nodename string, op iptsave.RenderState) []*iptsave.IPchain

func MakeRomanaClient

func MakeRomanaClient(config *NetConf) (*client.Client, error)

MakeRomanaClient creates romana rest client from CNI config.

func SetupVeth

func SetupVeth(contVethName, hostVethName string, mtu int, hostNS ns.NetNS) (net.Interface, net.Interface, error)

SetupVeth sets up a pair of virtual ethernet devices. Call SetupVeth from inside the container netns. It will create both veth devices and move the host-side veth into the provided hostNS namespace. On success, SetupVeth returns (hostVeth, containerVeth, nil)

Types

type DefaultAddressManager

type DefaultAddressManager struct{}

func (DefaultAddressManager) Allocate

func (DefaultAddressManager) Deallocate

func (DefaultAddressManager) Deallocate(config NetConf, client *client.Client, targetName string) error

type IP

type IP struct {
	net.IP
}

IP structure is basically net.IP, but we redefine it so we can implement Valuer and Scanner interfaces on it for storage.

func (*IP) Scan

func (i *IP) Scan(src interface{}) error

Scan implements driver.Scanner interface on IP

func (IP) Value

func (i IP) Value() (driver.Value, error)

Value implements driver.Valuer interface on IP

type K8sArgs

type K8sArgs struct {
	types.CommonArgs
	IP                         net.IP
	K8S_POD_NAME               types.UnmarshallableString
	K8S_POD_NAMESPACE          types.UnmarshallableString
	K8S_POD_INFRA_CONTAINER_ID types.UnmarshallableString
}

K8sArgs is the valid CNI_ARGS used for Kubernetes.

func (K8sArgs) MakePodName

func (k8s K8sArgs) MakePodName() string

MakePodName returns unique pod name.

func (K8sArgs) MakeVethName

func (k8s K8sArgs) MakeVethName() string

MakeVethName generates veth name that can be used for external part of the veth interface.

type NetConf

type NetConf struct {
	types.NetConf
	MTU int `json:"mtu"`

	KubernetesConfig string `json:"kubernetes_config"`

	RomanaClientConfig common.Config `json:"romana_client_config"`

	// Name of a current host in romana.
	// If omitted, current hostname will be used.
	RomanaHostName   string `json:"romana_host_name"`
	SegmentLabelName string `json:"segment_label_name"`
	TenantLabelName  string `json:"tenant_label_name"` // TODO for stas, we don't use it. May be it should go away.
	UseAnnotations   bool   `json:"use_annotations"`
	LogFile          string `json:"log_file"`
	Policy           bool   `json:"use_policy"`
}

NetConf represents parameters CNI plugin receives via stdin.

type NetIf

type NetIf struct {
	Name string `form:"interface_name" sql:"unique"`
	Mac  string `form:"mac_address" gorm:"primary_key"`
	IP   IP     `form:"ip_address" sql:"TYPE:varchar"`
}

NetIf is a structure that represents network interface and its IP configuration together with basic methods operating on this structure.

func (NetIf) GetIP

func (n NetIf) GetIP() net.IP

GetIP implements firewall.FirewallEndpoint

func (NetIf) GetMac

func (n NetIf) GetMac() string

GetMac implements firewall.FirewallEndpoint

func (NetIf) GetName

func (n NetIf) GetName() string

GetName implements firewall.FirewallEndpoint

func (NetIf) MarshalJSON

func (n NetIf) MarshalJSON() ([]byte, error)

MarshalJSON properly marshals NetIf structure.

func (*NetIf) SetIP

func (n *NetIf) SetIP(ip string) error

SetIP parses and sets the IP address of the interface.

func (*NetIf) UnmarshalJSON

func (n *NetIf) UnmarshalJSON(data []byte) error

UnmarshalJSON results in having NetIf implement Unmarshaler interface from encoding/json. This is needed because we use a type like net.IP here, not a simple type, and so a call to net.ParseIP is required to unmarshal this properly.

type NetworkRequest

type NetworkRequest struct {
	NetIf NetIf `json:"net_if,omitempty"`
	// TODO we should not need this tag
	Options map[string]string `json:"options,omitempty"`
}

NetworkRequest specifies messages sent to the agent containing information on how to configure network on its host.

type PodDescription

type PodDescription struct {
	Name        string
	Namespace   string
	Labels      map[string]string
	Annotations map[string]string
}

func GetPodDescription

func GetPodDescription(args K8sArgs, configFile string) (*PodDescription, error)

GetPodDescription retrieves additional information about pod that being created or deleted using CNI.

type RomanaAddressManager

type RomanaAddressManager interface {
	Allocate(NetConf, *client.Client, RomanaAllocatorPodDescription) (*net.IPNet, error)
	Deallocate(NetConf, *client.Client, string) error
}

RomanaAddressManager describes functions that allow allocating and deallocating IP addresses from Romana.

func NewRomanaAddressManager

func NewRomanaAddressManager(provider RomanaAddressManagerProvider) (RomanaAddressManager, error)

NewRomanaAddressManager returns structure that satisfies RomanaAddresManager, it allows multiple implementations.

type RomanaAddressManagerProvider

type RomanaAddressManagerProvider string
const DefaultProvider RomanaAddressManagerProvider = "default"

DefaultProvider allocates and deallocates IP addresses using rest requests to Romana IPAM.

type RomanaAllocatorPodDescription

type RomanaAllocatorPodDescription struct {
	Name        string
	Hostname    string
	Namespace   string
	Labels      map[string]string
	Annotations map[string]string
}

RomanaAllocatorPodDescription represents collection of parameters used to allocate IP address.

Jump to

Keyboard shortcuts

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