contrailCni

package
v0.0.0-...-b98a061 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4

Copyright (c) 2017 Juniper Networks, Inc. All rights reserved.

Copyright (c) 2018 Juniper Networks, Inc. All rights reserved.

vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4

Copyright (c) 2017 Juniper Networks, Inc. All rights reserved.

***************************************************************************

  • VRouter routines for CNI plugin ***************************************************************************

Index

Constants

View Source
const CNI_CONF_DIR = "/etc/cni/net.d/"
View Source
const CNI_MODE_K8S = "k8s"

Container orchestrator modes

View Source
const CNI_MODE_MESOS = "mesos"
View Source
const CONTRAIL_CNI_NAME = "contrail-k8s-cni"
View Source
const CONTRAIL_CONF_FILE = "contrail.conf"
View Source
const CONTRAIL_PARENT_INTERFACE = "eth0"

In case of macvlan, the container interfaces will run as sub-interface to interface on host network-namespace. Name of the interface inside host network-namespace is defined below

View Source
const FileNotExist = "File/Dir does not exist"

FileNotExist error message

View Source
const K8S_CLUSTER_NAME = "k8s"
View Source
const LOG_FILE = "/var/log/contrail/cni/opencontrail.log"
View Source
const LOG_LEVEL = "4"
View Source
const META_PLUGIN = "multus"
View Source
const VIF_TYPE_ETH = "eth"
View Source
const VIF_TYPE_MACVLAN = "macvlan"
View Source
const VIF_TYPE_VETH = "veth"

Type of virtual interface to be created for container

View Source
const VROUTER_AGENT_IP = "127.0.0.1"

Default VRouter values

View Source
const VROUTER_AGENT_PORT = 9091
View Source
const VROUTER_CONFIG_DIR = "/var/lib/contrail/ports/vm"

Directory containing configuration for the container

View Source
const VROUTER_POLL_RETRIES = 20
View Source
const VROUTER_POLL_TIMEOUT = 3

Variables

View Source
var CNIVersion string

CNIVersion is the version from the network configuration

View Source
var MetaPluginCall bool

Functions

func MakeCniResult

func MakeCniResult(ifname string, vrouterResult *Result) *current.Result

Convert result from VRouter format to CNI format

Types

type Annotations

type Annotations struct {
	Cluster   string `json:"cluster"`
	Kind      string `json:"kind"`
	Name      string `json:"name"`
	Namespace string `json:"namespace"`
	Network   string `json:"network"`
	Owner     string `json:"owner"`
	Project   string `json:"project"`
	Index     string `json:"index"`
	Interface string `json:"interface"`
}

Annotations are used to pass information from kube-manager to Plugin

type ContrailCni

type ContrailCni struct {
	ContainerUuid string
	ContainerName string
	ContainerVn   string
	ClusterName   string `json:"cluster-name"`
	Mode          string `json:"mode"`
	MetaPlugin    string `json:"meta-plugin"`
	VifParent     string `json:"parent-interface"`
	VifType       string `json:"vif-type"`
	Mtu           int    `json:"mtu"`
	NetworkName   string `json:"network-name"`
	MesosIP       string `json:"mesos-ip"`
	MesosPort     string `json:"mesos-port"`
	LogFile       string `json:"log-file"`
	LogLevel      string `json:"log-level"`
	VRouter       VRouter
	// contains filtered or unexported fields
}

Definition of Logging arguments in form of json in STDIN

func Init

func Init(args *skel.CmdArgs) (*ContrailCni, error)

func (*ContrailCni) CmdAdd

func (cni *ContrailCni) CmdAdd() error

* CmdAdd - Method to * - ADD handler for a container * - Pre-fetch interface configuration from VRouter. * - Gets MAC address for the interface * - In case of sub-interface, gets VLAN-Tag for the interface * - Create interface based on the "mode" * - Invoke Add handler from VRouter module * - Update interface with configuration got from VRouter * - Configures IP address * - Configures routes * - Bring-up the interface * - Return result in form of types.Result

func (*ContrailCni) CmdDel

func (cni *ContrailCni) CmdDel() error

***************************************************************************

  • Delete message handlers ***************************************************************************

func (*ContrailCni) Log

func (cni *ContrailCni) Log()

func (*ContrailCni) UpdateContainerInfo

func (cni *ContrailCni) UpdateContainerInfo(containerName, containerUuid,
	containerVn string)

func (*ContrailCni) UpdateContainerUuid

func (cni *ContrailCni) UpdateContainerUuid(containerUuid string)

type Result

type Result struct {
	VmUuid      string   `json:"vm-uuid"`
	Nw          string   `json:"network-label"`
	Ip          string   `json:"ip-address"`
	Plen        int      `json:"plen"`
	Gw          string   `json:"gateway"`
	Dns         string   `json:"dns-server"`
	Mac         string   `json:"mac-address"`
	VlanId      int      `json:"vlan-id"`
	VnId        string   `json:"vn-id"`
	VnName      string   `json:"vn-name"`
	VmiUuid     string   `json:"id"`
	Args        []string `json:"annotations"`
	Annotations Annotations
}

type VRouter

type VRouter struct {
	Server      string `json:"vrouter-ip"`
	Port        int    `json:"vrouter-port"`
	Dir         string `json:"config-dir"`
	PollTimeout int    `json:"poll-timeout"`
	PollRetries int    `json:"poll-retries"`

	VmiUuid string
	// contains filtered or unexported fields
}

struct to hold data for a connection to VRouter Agent

func VRouterInit

func VRouterInit(stdinData []byte, dataBytes []byte) (*VRouter, error)

func (*VRouter) Add

func (vrouter *VRouter) Add(containerName, containerUuid, containerVn,
	containerId, containerNamespace, containerIfName,
	hostIfName, vmiUuid string, updateAgent bool) error

Process add of a VM. Writes config file and send message to agent

func (*VRouter) CanDelete

func (vrouter *VRouter) CanDelete(containerName, containerId, containerUuid,
	containerVn string) (string, []string, []string, error)

* If a container fails (due to CNI failure or otherwise), kubelet will * delete the failed container and create a new one. In some cases kubelet * is calling CNI multiple times for failed container. We create interface * with names based on POD-UUID. So, both new and old container will map to * same tap interface name. * * If delete of the container comes after new container is spawned, the delete * must be ignored. When new container is created, the config file stored by * vrouter is updated with new container-id. Compare the container-id in * in this instance with one present in the config file. Ignore the request if * they do not match

func (*VRouter) Close

func (vrouter *VRouter) Close() error

***************************************************************************

  • VRouter handlers ***************************************************************************

func (*VRouter) Del

func (vrouter *VRouter) Del(containerId, containerUuid,
	containerVn string, updateAgent bool, vmiUuids []string) error

Process delete VM. The method ignores intermediate errors and does best * effort cleanup

func (*VRouter) Get

func (vrouter *VRouter) Get(url, containerNameUuid,
	vmiUuid string) (*[]Result, error)

Get operation from VRouter

func (*VRouter) Log

func (vrouter *VRouter) Log()

func (*VRouter) PollVm

func (vrouter *VRouter) PollVm(containerUuid,
	vmiUuid string) (*[]Result, error)

Poll response from VRouter

func (*VRouter) PollVmCfg

func (vrouter *VRouter) PollVmCfg(containerName string) (*[]Result,
	error)

***************************************************************************

  • POLL handling ***************************************************************************

Jump to

Keyboard shortcuts

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