Documentation
¶
Index ¶
- Constants
- Variables
- func DevicesByClaimUID(tbl statedb.Table[*DRADevice], txn statedb.ReadTxn, claimUID kube_types.UID) iter.Seq2[*DRADevice, statedb.Revision]
- type DRADevice
- type Driver
- func (d *Driver) HandleError(ctx context.Context, err error, msg string)
- func (driver *Driver) PrepareResourceClaims(ctx context.Context, claims []*resourceapi.ResourceClaim) (result map[kube_types.UID]kubeletplugin.PrepareResult, err error)
- func (driver *Driver) RunPodSandbox(ctx context.Context, podSandbox *api.PodSandbox) error
- func (driver *Driver) Start(ctx cell.HookContext) error
- func (driver *Driver) Stop(ctx cell.HookContext) error
- func (driver *Driver) StopPodSandbox(ctx context.Context, podSandbox *api.PodSandbox) error
- func (driver *Driver) Synchronize(ctx context.Context, pods []*api.PodSandbox, _ []*api.Container) ([]*api.ContainerUpdate, error)
- func (driver *Driver) UnprepareResourceClaims(ctx context.Context, claims []kubeletplugin.NamespacedObject) (result map[kube_types.UID]error, err error)
- func (d *Driver) WatchHealthStatus(ctx context.Context, reports chan<- kubeletplugin.DeviceHealthReport) error
- type NetworkDriverConfig
Constants ¶
const DevicesTableName = "networkdriver-dra-devices"
Variables ¶
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 ¶
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) TableHeader ¶
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
func (*Driver) HandleError ¶
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 ¶
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 ¶
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)