networkdriver

package
v1.21.0-pre.2 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 52 Imported by: 0

Documentation

Index

Constants

View Source
const DevicesTableName = "networkdriver-dra-devices"

Variables

View Source
var Cell = cell.Module(
	"network-driver",
	"Cilium Network Driver",

	cell.Config(defaultNetworkDriverConfig),

	cell.ProvidePrivate(
		ciliumNetworkDriverConfigResource,
		resourceClaimResource,
		podResource,
		newDeviceTable,
	),
	cell.Invoke(registerNetworkDriver),
)

Cell implements the Cilium Network Driver for exposing network devices to workloads.

Functions

func DevicesByClaimUID

func DevicesByClaimUID(tbl statedb.Table[*DRADevice], txn statedb.ReadTxn, claimUID kube_types.UID) iter.Seq2[*DRADevice, statedb.Revision]

DevicesByClaimUID returns all devices allocated for the given claim UID.

Types

type DRADevice

type DRADevice struct {
	// Name is the device name assigned by the device manager.
	// It is the primary key and the name used in ResourceSlice advertisements.
	// It does not necessarily match the kernel interface name.
	Name    string
	Manager types.DeviceManagerType
	Dev     types.Device

	// Allocation fields — non-zero when the device is prepared for a pod.
	Pool     string
	PodUID   kube_types.UID
	ClaimUID kube_types.UID
	Config   types.DeviceConfig
}

DRADevice represents a device known to the network driver.

Discovery fields (Name, Manager, Dev) are always present.

Allocation fields (PodUID, ClaimUID, Config) are non-zero when the device has been prepared for a pod via PrepareResourceClaims, and are cleared by UnprepareResourceClaims. On agent restart they are restored from the ResourceClaim status via restoreDevices.

func (*DRADevice) Clone

func (d *DRADevice) Clone() *DRADevice

func (*DRADevice) TableHeader

func (d *DRADevice) TableHeader() []string

func (*DRADevice) TableRow

func (d *DRADevice) TableRow() []string

type Driver

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

func (*Driver) HandleError

func (d *Driver) HandleError(ctx context.Context, err error, msg string)

HandleError logs out error messages from kubelet.

func (*Driver) PrepareResourceClaims

func (driver *Driver) PrepareResourceClaims(ctx context.Context, claims []*resourceapi.ResourceClaim) (result map[kube_types.UID]kubeletplugin.PrepareResult, err error)

PrepareResourceClaims gets called when we have a request to allocate a resource claim. we also need to have a way to remember the allocations elsewhere so allocation state persist across restarts in the plugin.

func (*Driver) RunPodSandbox

func (driver *Driver) RunPodSandbox(ctx context.Context, podSandbox *api.PodSandbox) error

RunPodSandbox is called by the container runtime when a pod sandbox is started. It configures the allocated network devices for the pod based on its network namespace.

func (*Driver) Start

func (driver *Driver) Start(ctx cell.HookContext) error

Start retrieves and validates the configuration. If configuration is found and valid, it initializes all the devicemanagers that are enabled by config, and starts the DRA + NRI registration.

func (*Driver) Stop

func (driver *Driver) Stop(ctx cell.HookContext) error

Stop stops the nri and dra hooks.

func (*Driver) StopPodSandbox

func (driver *Driver) StopPodSandbox(ctx context.Context, podSandbox *api.PodSandbox) error

StopPodSandbox is called when a pod sandbox is stopped. It cleans up the allocated network devices for the pod.

func (*Driver) Synchronize

func (driver *Driver) Synchronize(ctx context.Context, pods []*api.PodSandbox, _ []*api.Container) ([]*api.ContainerUpdate, error)

Synchronize is invoked by the runtime when the NRI plugin (re)connects — notably right after an agent restart — with every running pod. The sandbox tasks are alive here, so the netns is populated; we capture it so a later StopPodSandbox can recover the netns on containerd < 2.1 even across an agent restart. This mirrors how the statedb device table is rebuilt from ResourceClaims on restart: node-local runtime state reconstructed from a durable source rather than persisted to disk. We request no container updates.

func (*Driver) UnprepareResourceClaims

func (driver *Driver) UnprepareResourceClaims(ctx context.Context, claims []kubeletplugin.NamespacedObject) (result map[kube_types.UID]error, err error)

UnprepareResourceClaims gets called whenever we have a request to deallocate a resource claim. ex: pod goes away.

func (*Driver) WatchHealthStatus

func (d *Driver) WatchHealthStatus(ctx context.Context, reports chan<- kubeletplugin.DeviceHealthReport) error

WatchHealthStatus reports device health to the kubelet. The driver does not track device health, so it declines the service: the kubelet is told the stream is unimplemented and stops watching.

type NetworkDriverConfig

type NetworkDriverConfig struct {
	Enabled bool `mapstructure:"enable-network-driver"`
}

func (NetworkDriverConfig) Flags

func (cfg NetworkDriverConfig) Flags(flags *pflag.FlagSet)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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