deviceplugin

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package deviceplugin is the kubelet device plugin of the node-agent. It advertises one extended resource, cybericebox.com/tun, and a pod that requests it gets /dev/net/tun passed by the kubelet and nothing else from the host: that is how the `extended` device profile reaches tun without a privileged container or a hostPath.

Index

Constants

View Source
const TUNDevice = "/dev/net/tun"

TUNDevice is the host path of the tun device the plugin hands out; the container sees it at the same path.

Variables

This section is empty.

Functions

This section is empty.

Types

type Plugin

type Plugin struct {
	pluginapi.UnimplementedDevicePluginServer

	Resource string // cybericebox.com/tun
	Dir      string // the kubelet's device-plugins directory
	Slots    int
	HostPath string // the device on the host as the kubelet sees it (what a container gets); default TUNDevice
	// CheckPath is what THIS process looks at to see that the device exists on the host. A container's /dev is minimal and has no tun
	// even when the host does, so the node-agent checks the kernel's sysfs entry of the tun misc device, /sys/class/misc/tun/dev
	// (present exactly when the tun module is loaded; sysfs shows the host's kernel in a container, read-only, no extra mount).
	// Any path there only has to exist. Empty: HostPath, which must then be a character device.
	CheckPath string
	Interval  time.Duration
	Log       logr.Logger
	// contains filtered or unexported fields
}

Plugin serves one resource. Its devices are interchangeable virtual slots (the same /dev/net/tun for each), so a node can run as many extended devices as it has slots; the count only bounds that.

func (*Plugin) Allocate

Allocate answers with the tun device for every container request: that is all the kubelet passes.

func (*Plugin) GetDevicePluginOptions

func (p *Plugin) GetDevicePluginOptions(context.Context, *pluginapi.Empty) (*pluginapi.DevicePluginOptions, error)

func (*Plugin) ListAndWatch

ListAndWatch sends the devices, and again whenever the health of the host device changes (it appears or goes away).

func (*Plugin) Serve

func (p *Plugin) Serve(ctx context.Context) error

Serve listens on the plugin's socket in the kubelet directory and registers with the kubelet; it registers again when the kubelet restarts (its socket is replaced). It returns when ctx ends.

func (*Plugin) SetCheckPath

func (p *Plugin) SetCheckPath(path string)

SetCheckPath changes where the plugin checks the device exists (tests move it).

func (*Plugin) SetHostPath

func (p *Plugin) SetHostPath(path string)

SetHostPath changes the device the plugin looks for (tests move it); the check path follows unless one was set.

Jump to

Keyboard shortcuts

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