Documentation ¶
Index ¶
- Constants
- Variables
- func ConfigureOVS(ctx context.Context, namespace, podName, hostIfaceName string, ...) error
- func GetPodSource(pod *kapi.Pod) (string, error)
- func GetPodWithAnnotations(ctx context.Context, getter PodInfoGetter, namespace, name, nadName string, ...) (*kapi.Pod, map[string]string, *util.PodAnnotation, error)
- func HandlePodRequest(request *PodRequest, clientset *ClientSet, kubeAuth *KubeAPIAuth, ...) ([]byte, error)
- func IsStaticPod(pod *kapi.Pod) bool
- func ResetRunner()
- func SetExec(r kexec.Interface) error
- type CNIPluginLibOps
- type CNIRequestMetrics
- type ClientSet
- type KubeAPIAuth
- type Plugin
- type PodInfoGetter
- type PodInterfaceInfo
- type PodRequest
- type PodRequestInterfaceOps
- type Request
- type Response
- type Server
Constants ¶
const ( Egress direction = iota Ingress )
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
const CNIAdd command = "ADD"
CNIAdd is the command representing add operation for a new pod
const CNICheck command = "CHECK"
CNICheck is the command representing check operation on a pod
const CNIDel command = "DEL"
CNIDel is the command representing delete operation on a pod that is to be torn down
const CNIUpdate command = "UPDATE"
CNIUpdate is the command representing update operation for an existing pod
const ServerRunDir string = "/var/run/ovn-kubernetes/cni/"
ServerRunDir is the default directory for CNIServer runtime files
Variables ¶
var (
BandwidthNotFound = ¬FoundError{}
)
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 ¶
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 ¶
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
Types ¶
type CNIPluginLibOps ¶
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 ¶
NewCNIPlugin creates the internal Plugin object
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) MarshalForLogging ¶
Filter out kubeAuth, since it might contain sensitive information.
type Server ¶
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 ¶
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.