Documentation ¶
Overview ¶
Romana CNI plugin configures kubernetes pods on Romana network.
Index ¶
- Constants
- func AddEndpointRoute(ifaceName string, ip *net.IPNet, nl nlRouteHandle) error
- func CmdAdd(args *skel.CmdArgs) error
- func CmdDel(args *skel.CmdArgs) error
- func MakeDivertRules(nodename string, op iptsave.RenderState) []*iptsave.IPchain
- func MakeRomanaClient(config *NetConf) (*client.Client, error)
- func SetupVeth(contVethName, hostVethName string, mtu int, hostNS ns.NetNS) (net.Interface, net.Interface, error)
- type DefaultAddressManager
- type IP
- type K8sArgs
- type NetConf
- type NetIf
- type NetworkRequest
- type PodDescription
- type RomanaAddressManager
- type RomanaAddressManagerProvider
- type RomanaAllocatorPodDescription
Constants ¶
const ( DefaultCNILogFile = "/var/log/romana/cni.log" AlternativeCNILogFile = "/var/tmp/romana-cni.log" )
const DefaultSegmentID = "default"
Variables ¶
This section is empty.
Functions ¶
func AddEndpointRoute ¶
AddEndpointRoute adds return /32 route from host to pod. This function is designed to take nil as nlRouteHandle argument.
func CmdAdd ¶
cmdAdd is a callback functions that gets called by skel.PluginMain in response to ADD method.
func CmdDel ¶
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 ¶
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) Allocate(config NetConf, client *client.Client, pod RomanaAllocatorPodDescription) (*net.IPNet, error)
func (DefaultAddressManager) Deallocate ¶
type IP ¶
IP structure is basically net.IP, but we redefine it so we can implement Valuer and Scanner interfaces on it for storage.
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 ¶
MakePodName returns unique pod name.
func (K8sArgs) MakeVethName ¶
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) MarshalJSON ¶
MarshalJSON properly marshals NetIf structure.
func (*NetIf) UnmarshalJSON ¶
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.