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
- Variables
- func MakeCniResult(ifname string, vrouterResult *Result) *current.Result
- type Annotations
- type ContrailCni
- type Result
- type VRouter
- func (vrouter *VRouter) Add(...) error
- func (vrouter *VRouter) CanDelete(containerName, containerId, containerUuid, containerVn string) (string, []string, []string, error)
- func (vrouter *VRouter) Close() error
- func (vrouter *VRouter) Del(containerId, containerUuid, containerVn string, updateAgent bool, ...) error
- func (vrouter *VRouter) Get(url, containerNameUuid, vmiUuid string) (*[]Result, error)
- func (vrouter *VRouter) Log()
- func (vrouter *VRouter) PollVm(containerUuid, vmiUuid string) (*[]Result, error)
- func (vrouter *VRouter) PollVmCfg(containerName string) (*[]Result, error)
Constants ¶
const CNI_CONF_DIR = "/etc/cni/net.d/"
const CNI_MODE_K8S = "k8s"
Container orchestrator modes
const CONTRAIL_CNI_NAME = "contrail-k8s-cni"
const CONTRAIL_CONF_FILE = "contrail.conf"
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
const FileNotExist = "File/Dir does not exist"
FileNotExist error message
const K8S_CLUSTER_NAME = "k8s"
const LOG_FILE = "/var/log/contrail/cni/opencontrail.log"
const LOG_LEVEL = "4"
const META_PLUGIN = "multus"
const OCP_CNI_CONF_DIR = "/etc/kubernetes/cni/net.d/"
const TF_CONF_FILE = "tf-cni.conf"
const VIF_TYPE_ETH = "eth"
const VIF_TYPE_MACVLAN = "macvlan"
const VIF_TYPE_VETH = "veth"
Type of virtual interface to be created for container
const VROUTER_AGENT_IP = "127.0.0.1"
Default VRouter values
const VROUTER_AGENT_PORT = 9091
const VROUTER_CONFIG_DIR = "/var/lib/contrail/ports/vm"
Directory containing configuration for the container
const VROUTER_POLL_RETRIES = 20
const VROUTER_POLL_TIMEOUT = 3
Variables ¶
var CNIVersion string
CNIVersion is the version from the network configuration
var MetaPluginCall bool
Functions ¶
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"` 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 (*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 (*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 ¶
***************************************************************************
- 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