cni

package
v0.0.0-...-c6fb7fd Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 48 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Egress direction = iota
	Ingress
)
View Source
const (
	ConfigSourceAnnotationKey = "kubernetes.io/config.source"
	// ApiserverSource identifies updates from Kubernetes API Server.
	ApiserverSource = "api"
)

START taken from https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/types/pod_update.go

View Source
const CNIAdd command = "ADD"

CNIAdd is the command representing add operation for a new pod

View Source
const CNICheck command = "CHECK"

CNICheck is the command representing check operation on a pod

View Source
const CNIDel command = "DEL"

CNIDel is the command representing delete operation on a pod that is to be torn down

View Source
const CNIUpdate command = "UPDATE"

CNIUpdate is the command representing update operation for an existing pod

View Source
const ServerRunDir string = "/var/run/ovn-kubernetes/cni/"

ServerRunDir is the default directory for CNIServer runtime files

Variables

View Source
var (
	BandwidthNotFound = &notFoundError{}
)

Functions

func ConfigureOVS

func ConfigureOVS(ctx context.Context, namespace, podName, hostIfaceName string,
	ifInfo *PodInterfaceInfo, sandboxID, deviceID string, getter PodInfoGetter) error

ConfigureOVS performs OVS configurations in order to set up Pod networking

func GetPodSource

func GetPodSource(pod *kapi.Pod) (string, error)

GetPodSource returns the source of the pod based on the annotation.

func GetPodWithAnnotations

func GetPodWithAnnotations(ctx context.Context, getter PodInfoGetter,
	namespace, name, nadName string, annotCond podAnnotWaitCond) (*kapi.Pod, map[string]string, *util.PodAnnotation, error)

GetPodAnnotations obtains the pod UID and annotation from the cache or apiserver

func HandlePodRequest

func HandlePodRequest(
	request *PodRequest,
	clientset *ClientSet,
	kubeAuth *KubeAPIAuth,
	networkManager networkmanager.Interface,
) ([]byte, error)

HandlePodRequest is the callback for all the requests coming to the cniserver after being processed into PodRequest objects Argument '*PodRequest' encapsulates all the necessary information kclient is passed in so that clientset can be reused from the server Return value is the actual bytes to be sent back without further processing.

func IsStaticPod

func IsStaticPod(pod *kapi.Pod) bool

IsStaticPod returns true if the pod is a static pod.

func ResetRunner

func ResetRunner()

ResetRunner used by unit-tests to reset runner to its initial (un-initialized) value

func SetExec

func SetExec(r kexec.Interface) error

Types

type CNIPluginLibOps

type CNIPluginLibOps interface {
	AddRoute(ipn *net.IPNet, gw net.IP, dev netlink.Link, mtu int) error
	SetupVeth(contVethName string, hostVethName string, mtu int, contVethMac string, hostNS ns.NetNS) (net.Interface, net.Interface, error)
}

type CNIRequestMetrics

type CNIRequestMetrics struct {
	Command     command `json:"command"`
	ElapsedTime float64 `json:"elapsedTime"`
	HasErr      bool    `json:"hasErr"`
}

CNIRequestMetrics info to report from CNI shim to CNI server

type ClientSet

type ClientSet struct {
	PodInfoGetter
	// contains filtered or unexported fields
}

func NewClientSet

func NewClientSet(kclient kubernetes.Interface, podLister corev1listers.PodLister) *ClientSet

type KubeAPIAuth

type KubeAPIAuth struct {
	// Kubeconfig is the path to a kubeconfig
	Kubeconfig string `json:"kubeconfig,omitempty"`
	// KubeAPIServer is the URL of a Kubernetes API server (not required if kubeconfig is given)
	KubeAPIServer string `json:"kube-api-server,omitempty"`
	// KubeAPIToken is a Kubernetes API token (not required if kubeconfig is given)
	KubeAPIToken string `json:"kube-api-token,omitempty"`
	// KubeAPITokenFile is the path to Kubernetes API token
	// If set, it is periodically read and takes precedence over KubeAPIToken
	KubeAPITokenFile string `json:"kube-api-token-file,omitempty"`
	// KubeCAData is the Base64-ed Kubernetes API CA certificate data (not required if kubeconfig is given)
	KubeCAData string `json:"kube-ca-data,omitempty"`
}

KubeAPIAuth contains information necessary to create a Kube API client

type Plugin

type Plugin struct {
	// contains filtered or unexported fields
}

Plugin is the structure to hold the endpoint information and the corresponding functions to use it

func NewCNIPlugin

func NewCNIPlugin(socketPath string) *Plugin

NewCNIPlugin creates the internal Plugin object

func (*Plugin) CmdAdd

func (p *Plugin) CmdAdd(args *skel.CmdArgs) error

CmdAdd is the callback for 'add' cni calls from skel

func (*Plugin) CmdCheck

func (p *Plugin) CmdCheck(args *skel.CmdArgs) error

CmdCheck is the callback for 'checking' container's networking is as expected.

func (*Plugin) CmdDel

func (p *Plugin) CmdDel(args *skel.CmdArgs) error

CmdDel is the callback for 'teardown' cni calls from skel

type PodInfoGetter

type PodInfoGetter interface {
	// contains filtered or unexported methods
}

type PodInterfaceInfo

type PodInterfaceInfo struct {
	util.PodAnnotation

	MTU                  int    `json:"mtu"`
	RoutableMTU          int    `json:"routable-mtu"`
	Ingress              int64  `json:"ingress"`
	Egress               int64  `json:"egress"`
	IsDPUHostMode        bool   `json:"is-dpu-host-mode"`
	SkipIPConfig         bool   `json:"skip-ip-config"`
	PodUID               string `json:"pod-uid"`
	NetdevName           string `json:"vf-netdev-name"`
	EnableUDPAggregation bool   `json:"enable-udp-aggregation"`

	// network name, for default network, it is "default", otherwise it is net-attach-def's netconf spec name
	NetName string `json:"netName"`
	// NADName, for default network, it is "default", otherwise, in the form of net-attach-def's <Namespace>/<Name>
	NADName string `json:"nadName"`
}

PodInterfaceInfo consists of interface info result from cni server if cni client configure's interface

func PodAnnotation2PodInfo

func PodAnnotation2PodInfo(podAnnotation map[string]string, podNADAnnotation *util.PodAnnotation, podUID,
	netdevname, nadName, netName string, mtu int) (*PodInterfaceInfo, error)

PodAnnotation2PodInfo creates PodInterfaceInfo from Pod annotations and additional attributes

type PodRequest

type PodRequest struct {
	// The CNI command of the operation
	Command command
	// kubernetes namespace name
	PodNamespace string
	// kubernetes pod name
	PodName string
	// kubernetes pod UID
	PodUID string
	// kubernetes container ID
	SandboxID string
	// kernel network namespace path
	Netns string
	// Interface name to be configured
	IfName string
	// CNI conf obtained from stdin conf
	CNIConf *types.NetConf

	// if CNIConf.DeviceID is present, then captures if the VF is of type VFIO or not
	IsVFIO bool
	// contains filtered or unexported fields
}

PodRequest structure built from Request which is passed to the handler function given to the Server at creation time

func (*PodRequest) String

func (pr *PodRequest) String() string

type PodRequestInterfaceOps

type PodRequestInterfaceOps interface {
	ConfigureInterface(pr *PodRequest, getter PodInfoGetter, ifInfo *PodInterfaceInfo) ([]*current.Interface, error)
	UnconfigureInterface(pr *PodRequest, ifInfo *PodInterfaceInfo) error
}

type Request

type Request struct {
	// CNI environment variables, like CNI_COMMAND and CNI_NETNS
	Env map[string]string `json:"env,omitempty"`
	// CNI configuration passed via stdin to the CNI plugin
	Config []byte `json:"config,omitempty"`
	// The DeviceInfo struct
	nadapi.DeviceInfo
}

Request sent to the Server by the OVN CNI plugin

type Response

type Response struct {
	Result    *current.Result
	PodIFInfo *PodInterfaceInfo
	KubeAuth  *KubeAPIAuth
}

Response sent to the OVN CNI plugin by the Server

func (*Response) Marshal

func (response *Response) Marshal() ([]byte, error)

func (*Response) MarshalForLogging

func (response *Response) MarshalForLogging() ([]byte, error)

Filter out kubeAuth, since it might contain sensitive information.

type Server

type Server struct {
	http.Server
	// contains filtered or unexported fields
}

Server object that listens for JSON-marshaled Request objects on a private root-only Unix domain socket.

func NewCNIServer

func NewCNIServer(
	factory factory.NodeWatchFactory,
	kclient kubernetes.Interface,
	networkManager networkmanager.Interface,
) (*Server, error)

NewCNIServer creates and returns a new Server object which will listen on a socket in the given path

func (*Server) Start

func (s *Server) Start(rundir string) error

Start the Server's local HTTP server on a root-owned Unix domain socket. handlePodRequestFunc will be called to handle pod setup/teardown operations on each request to the Server's HTTP server, and should return the response bytes, or an error when the operation has completed.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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